-
Notifications
You must be signed in to change notification settings - Fork 152
Enable flag on exposures to optionally exlcude nil attributes. #10
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
Conversation
@dblock or @mbleigh can you give me your thoughts on this. I am trying to think of an easy way to check the value of an attribute and hide it if it is nil. I am really undecided at this point if this should be an option at the entity level or at the individual exposure level. Either way, I think |
I think this is a pretty cool feature, and I definitely think it should be on a per-exposure basis. If you have a host of nullable exposures, you can use the new |
I like the feature, and also agree that it should be per-exposure. There are some attributes that you may want to expose as |
Note I'm not 100% if the current implementation is per-exposure, but it seems like the specs at least could use a bit more descriptive of names. |
I agree. The naming is bad. This was intended to talk about, I wasn't planning to merge until I cleanup the specs and make sure i've covered what I need to. The current implementation should be per-exposure. |
Bump. What do we want to do about this one? If anything it needs a line in CHANGELOG :) |
I need to fix it. I am just getting back into this now after some craziness. |
In the spirit of staying positive, I think this should be renamed to Note that |
Okay, I should have time towards the end of the week to fix this. I am going to fix the implementation and I like the |
So was this finally implemented? Thanks. |
This hasn't been merged, see discussion above. Need more work (from @idyll or others). |
Thanks @dblock http://stackoverflow.com/questions/21950613/grape-entities-conditional-expose-if-field-is-not-nil Hope it help. |
I am closing this and will reopen a new one with my changes, |
Was this ever re-opened in another issue? Would be a nice feature for with_options(expose_nil: false) do
expose :snow_route
expose :temporary_route
expose :construction_warning
end |
For certain APIs I find that it is best for the client if the API hide's attributes that are nil.
Instead of handling this in each serializer (json, plist, xml) I am looking for options to pull control over this into the entity.