Method: MongoidHashQuery::Aggregation#apply_aggregations

Defined in:
lib/mongoid_hash_query/aggregation.rb

#apply_aggregations(available_aggr, asked_aggr, field) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/mongoid_hash_query/aggregation.rb', line 55

def apply_aggregations(available_aggr, asked_aggr, field)
  meta_attributes = HashWithIndifferentAccess.new

  available_aggr.each do |k, v|
    if asked_aggr[k]
      meta_attributes[k] = resource.send(v,field)
      meta_attributes[k] = meta_attributes[k].to_f if meta_attributes[k].is_a? BigDecimal
    end
  end

  return meta_attributes
end