Skip to content

Instantly share code, notes, and snippets.

@judofyr
Forked from snuxoll/with_method.rb
Created March 14, 2009 17:44
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 judofyr/79132 to your computer and use it in GitHub Desktop.
Save judofyr/79132 to your computer and use it in GitHub Desktop.
# Mixin to scan an array for objects that respond to a given method
module WithMethod
# Iterates through the array and returns a list of items that
# respond to method
def with_method(method)
self.select do |item|
item.respond_to(method)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment