Module: Recollect::Array

Defined in:
lib/recollect/array.rb,
lib/recollect/array/hashie.rb,
lib/recollect/array/utility.rb,
lib/recollect/array/version.rb,
lib/recollect/array/filterable.rb,
lib/recollect/array/predicate/in.rb,
lib/recollect/array/predicate/equal.rb,
lib/recollect/array/predicate/endify.rb,
lib/recollect/array/predicate/contains.rb,
lib/recollect/array/predicate/startify.rb,
lib/recollect/array/predicate/less_than.rb,
lib/recollect/array/predicate/greater_than.rb

Defined Under Namespace

Modules: Contains, Endify, Equal, GreaterThan, GreaterThanEqual, Hashie, Included, LessThan, LessThanEqual, NotContains, NotEndify, NotEqual, NotIncluded, NotStartify, Startify, Utility Classes: Filterable

Constant Summary collapse

VERSION =
'0.1.3'

Class Method Summary collapse

Class Method Details

.filter(data, filters = {}) ⇒ Object

### Array.filter ‘filter value into Array using conditions

““ data = [{ a: 1, b: { c: 2 }, d: [‘1’] }] filters = { a_eq: 1, ‘b.c_eq’: 2, d_in: [‘1’] } Recollect::Array.filter(data, filters) ““



26
27
28
# File 'lib/recollect/array.rb', line 26

def self.filter(data, filters = {})
  Filterable.call(data, filters)
end

.pluck(data, iteratee) ⇒ Object

### Array.pluck ‘fetch value into Array, like Lodash#pluck`

““ data = [{ a: 1, b: { c: 2 }, d: [‘1’] }] Recollect::Array.pluck(data, ‘b.c’) ““



37
38
39
40
41
# File 'lib/recollect/array.rb', line 37

def self.pluck(data, iteratee)
  return [] unless data.any?

  data.map { |item| Hashie.get(item, iteratee) }
end