Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add conditional support to attribute #155

Closed
nesquena opened this Issue · 4 comments

3 participants

@nesquena
Owner

Add if support to attribute call

@databyte
Collaborator

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

@nesquena
Owner

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

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.
@nesquena
Owner

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.