-
-
Save judofyr/79132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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