Module: Shushu::LineItemBuilder
- Extended by:
- LineItemBuilder
- Included in:
- LineItemBuilder
- Defined in:
- lib/services/line_item_builder.rb
Instance Method Summary collapse
-
#build(units) ⇒ Object
Give build() a collection of units and it will return a collection of line_items.
Instance Method Details
#build(units) ⇒ Object
Give build() a collection of units and it will return a collection of line_items. Each line_item will have a collection of unit_groups wich will hold a collection of units
9 10 11 12 13 14 15 |
# File 'lib/services/line_item_builder.rb', line 9 def build(units) units.group_by(&:hid).map do |hid, units_by_hid| units_by_hid.group_by(&:product_name).map do |product_name, units_by_name| UnitGroup.new(units_by_name) end end.map {|unit_groups| LineItem.new(unit_groups)}.flatten end |