Skip to content

Instantly share code, notes, and snippets.

@aaronblohowiak
Forked from jaredatron/gist:100942
Created April 24, 2009 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronblohowiak/100953 to your computer and use it in GitHub Desktop.
Save aaronblohowiak/100953 to your computer and use it in GitHub Desktop.
# Behavior filter turns method names into select/reject filters
# Example
# class User
# has_manny :comments, :extend => BehaviorFilter
# end
module BehaviorFilter
# creates magic methods like these
# user.comments.from_blocked_commentors
# # => user.comments.select{ |c| user.blocking?(c.commentor) }
#
# user.comments.without_idolized_commentors
# # => user.comments.reject{ |c| user.idolizing?(c.commentor) }
def method_missing(method, *args)
#blah blah blah
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment