Module: SelectWhere
- Defined in:
- lib/select_where.rb,
lib/select_where/helpers.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
- .detect(array, match_hash) ⇒ Object
- .fetch_map(array, *args, &block) ⇒ Object
- .select(array, match_hash) ⇒ Object
Class Method Details
.detect(array, match_hash) ⇒ Object
5 6 7 |
# File 'lib/select_where.rb', line 5 def self.detect(array, match_hash) array.detect { |i| match_hash.each.all? { |k,v| ::SelectWhere::Helpers.item_matches_target?(i, k, v) }} end |
.fetch_map(array, *args, &block) ⇒ Object
13 14 15 |
# File 'lib/select_where.rb', line 13 def self.fetch_map(array, *args, &block) array.map { |i| i.fetch(*args, &block) } end |
.select(array, match_hash) ⇒ Object
9 10 11 |
# File 'lib/select_where.rb', line 9 def self.select(array, match_hash) array.select { |i| match_hash.each.all? { |k,v| ::SelectWhere::Helpers.item_matches_target?(i, k, v) }} end |