Skip to content

Extract Resource#find's resource transformation#718

Merged
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
rfb:topic/abstract_resources_for
May 23, 2016
Merged

Extract Resource#find's resource transformation#718
lgebhardt merged 1 commit intoJSONAPI-Resources:masterfrom
rfb:topic/abstract_resources_for

Conversation

@rfb
Copy link
Copy Markdown
Contributor

@rfb rfb commented May 20, 2016

Most of the behaviour of JSONAPI::Resource#find can be controlled by
reimplementing #records, #filter_record, #sort_record, etc. By moving the
resource transformation into #resources_for, we've remove one of the final bits
of logic out of the #find. All #find defines is the order of operations and in
many cases can be left as is.

My specific use case is to delegate a single class of models to different
resources. The caching behaviour in #find's transformation prevents me from
simply reimplementing Resource#resource_for.

Most of the behaviour of JSONAPI::Resource#find can be controlled by
reimplementing #records, #filter_record, #sort_record, etc. By moving the
resource transformation into #resources_for, we've remove one of the final bits
of logic out of the #find. All #find defines is the order of operations and in
many cases can be left as is.

My specific use case is to delegate a single class of models to different
resources. The caching behaviour in #find's transformation prevents me from
simply reimplementing Resource#resource_for.
@lgebhardt lgebhardt merged commit 4015be1 into JSONAPI-Resources:master May 23, 2016
@lgebhardt
Copy link
Copy Markdown
Contributor

@rfb Thanks!

@rfb
Copy link
Copy Markdown
Contributor Author

rfb commented May 23, 2016

Great, thanks @lgebhardt - great work on JSONAPI::Resources! it's been a pleasure to implement into our stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants