Class: Array
Overview
Array extensions
Instance Method Summary collapse
-
#select_with_hash(conditions = {}) ⇒ Object
Example nodes.select_with_hash(:status=>‘running’).
Instance Method Details
#select_with_hash(conditions = {}) ⇒ Object
Example nodes.select_with_hash(:status=>‘running’)
8 9 10 11 12 13 14 15 |
# File 'lib/core/array.rb', line 8 def select_with_hash(conditions={}) return self if conditions.empty? select do |node| conditions.any? do |k,v| ( node.has_key?(k) && node[k]==v ) or ( node.respond_to?(k) && node.send(k)==v ) end end end |