-
Notifications
You must be signed in to change notification settings - Fork 420
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
ability to customize rendering of attributes via a block #54
ability to customize rendering of attributes via a block #54
Conversation
Add missing attribute in README example
I prefer this solution than other one 👍 I might have to say the other solution could cause little bit of performance degradation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer this method, would there be confusion around attributes
vs attribute
for users of this library?
@grossadamm Good question. Currently attribute :name
attributes :release_year do
...
end
attributes :actor_names, :starring do |record|
record.actors.map(&:name).join(', ')
end Not sure why you would ever want to have multiple attributes evaluate to the same block, but it's possible... maybe if you're using |
I like this implementation, makes complete sense since we try to avoid instantiating serializer objects. Maybe the attribute alias should be in another PR though |
@christophersansone please resolve the conflicts so that I can merge this. Could you also add to documentation an example of how to use the custom attributes feature with blocks? Thank you for being patient and helping with trying out all the different ideas. |
I think you have to rebase on |
@shishirmk Ready to go! |
👏 |
* add hash benchmarking to performance tests * Add missing attribute in README example * Disable GC before doing performance test * Enable oj to AM for fair benchmark test * ability to customize rendering of attributes via a block * fixed attribute render spec * minimized specs to specifially test this feature * Update README to include attribute definitions * Fixed syntax error * Fixed merge issues
Fixes #5. Solves the same problem as #49 but with a minimal code change. The serialization declaration is somewhat different as well.
Example: