class Hash
   def to_proc
     proc { |o| all? { |k, v| v === o[k] } }
   end
 end

This would allow to use Hash as a proc argument for methods in *Enumerable* 
module:

array = [{ key: "a" }, { key: "2aZ" }, { key: 12 }]


array.find(&{key: /Z/}) # => { key: "2aZ" }
array.select(&{key: 1..20}) # => [{ key: 12}]

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to