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}]
``