-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add params to set_id block #16
Conversation
Pull request #331 added a block to the ObjectSerializer.set_id class method, which allows passing a block to the set_id method. Currently this block takes only one argument `record`: ``` set_id do |record| "#{record.name.downcase}-#{record.id}" end ``` This PR adds another argument `params` to the block: ``` set id do |record, params| params[:admin] ? record.id : "#{record.name.downcase}-#{record.id}" end ``` This customization can be useful in situation where we serve different clients that may need different IDs. One nice side effect is also that the `set_id` method has the same method signature as the `attribute` method.
@stas This looks good to me. Can you explain why this is a breaking change. The optional second |
@henvo I updated the PR to merge into the dev branch. Can you resolve the conflicts? |
Hey all thanks for the feedback. I fixed the merge conflicts. |
Hey thanks for creating this repo and keeping fast_jsonapi alive
A previous pull request added a block to the ObjectSerializer.set_id class
method, which allows passing a block to the set_id method. Currently
this block takes only one argument
record
:This PR adds another argument params to the block:
This customization can be useful in situation where we serve different
clients that may need different IDs. One nice side effect is also that
the set_id method has the same method signature as the attribute
method.
This PR was copied from Netflix/fast_jsonapi#380