Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add conditional support to attribute #155

Closed
nesquena opened this Issue Jan 26, 2012 · 4 comments

Comments

Projects
None yet
3 participants
Owner

nesquena commented Jan 26, 2012

Add if support to attribute call

Collaborator

databyte commented Apr 6, 2012

Want to add this on to Issue #216? Not sure what you meant.

Owner

nesquena commented Apr 6, 2012

The idea was to do:

attribute :foo, :if => lambda { ... } 

in case people need to apply conditionals to a collection:

collection @posts

attribute :foo, :if => lambda { |p| p.admin? }

chaupt commented Apr 6, 2012

I might have missed this, but would there be a clean way to apply a condition to a list (other than to spell them all out?)? I'm thinking in particular the case of nil attributes not writing out:

attribute :foo, :bar, :zot, :unless => lambda {|x, attributename| x.attributename.nil?}

I often have large JSON objects that I want to emit, but don't want a bunch of "field": null type results. Thoughts or pointers?

Owner

nesquena commented Sep 3, 2013

This is fixed in recent versions

@nesquena nesquena closed this Sep 3, 2013

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