Added presenter method attr_expose to AR#41
Open
adamburmister wants to merge 3 commits into
Open
Conversation
…attributes to expose (using the new attr_expose method)
Owner
|
I like the idea - it's nice and simple yet suitable powerful! I'm not sure it's something that necessarily belongs in RocketPants itself at the moment. I'd be more inclined to add it as a |
|
Just came across this Did anyone put these into a gem that could we could hook in? |
Owner
|
@softwaregravy I'm not aware of a gem, but you can solve it pretty similarly (using different syntax, and admittedly a bit more weight) using ActiveModel Serializers integration. |
|
I did end up going with the Serializers, thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a method
attr_exposeto the AR model which allows for easy declaration of attributes to include in the JSON response.Under the cover it stores a list of attribute names and automatically passes those into the
options[:only]array whenserializable_hashis called.