Class: Mongoid::Report::Merger
- Inherits:
-
Struct
- Object
- Struct
- Mongoid::Report::Merger
- Defined in:
- lib/mongoid/report/merger.rb
Overview
We are using this class to combine results by group by fields.
Instance Attribute Summary collapse
-
#groups ⇒ Object
Returns the value of attribute groups.
Instance Method Summary collapse
Instance Attribute Details
#groups ⇒ Object
Returns the value of attribute groups
5 6 7 |
# File 'lib/mongoid/report/merger.rb', line 5 def groups @groups end |
Instance Method Details
#do(rows) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/mongoid/report/merger.rb', line 6 def do(rows) # Merge by groups. rows .group_by { |row| groups.map { |group| row[group] }.join('-') } .values .map { |array_row| combine(array_row) } end |