Created
September 15, 2010 21:53
-
-
Save tjbladez/581558 to your computer and use it in GitHub Desktop.
This file contains 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
# to deal with array of hashes | |
module ArrayExtensions | |
def where(criteria ={}) | |
result = self | |
criteria.each do |cr_key, cr_value| | |
result = result.select do |hash| | |
hash[cr_key].to_s.match(/#{cr_value}/i) | |
end | |
end | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment