Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add conditional support to attribute #155

nesquena opened this Issue · 4 comments

3 participants


Add if support to attribute call


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


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? }

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?

@ismaelga ismaelga referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.

This is fixed in recent versions

@nesquena nesquena closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.