Skip to content

Instantly share code, notes, and snippets.

@snuxoll
Created March 14, 2009 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save snuxoll/79131 to your computer and use it in GitHub Desktop.
Save snuxoll/79131 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)
select { |item| item.respond_to? method }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment