class Stunted::HashArray

Public Instance Methods

collapse_and_aggregate(*keys) { |collection| ... } click to toggle source
# File lib/stunted/hash-array.rb, line 6
def collapse_and_aggregate(*keys)
  keys.reduce(first) do | accumulator, key |
    collection = collect(&key)
    collection = yield(collection) if block_given?
    accumulator.merge(key => collection)
  end
end
segregate_by_key(key) click to toggle source
# File lib/stunted/hash-array.rb, line 14
def segregate_by_key(key)
  group_by(&key).values.collect do | inner | 
    self.class.new(inner)
  end
end