Skip to content

Instantly share code, notes, and snippets.

@tjbladez
Created September 15, 2010 21:53
Show Gist options
  • Save tjbladez/581558 to your computer and use it in GitHub Desktop.
Save tjbladez/581558 to your computer and use it in GitHub Desktop.
# 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