Class: Spree::Stock::InventoryUnitBuilder
- Inherits:
-
Object
- Object
- Spree::Stock::InventoryUnitBuilder
- Defined in:
- app/models/spree/stock/inventory_unit_builder.rb
Instance Method Summary collapse
-
#initialize(order) ⇒ InventoryUnitBuilder
constructor
A new instance of InventoryUnitBuilder.
- #missing_units_for_line_item(line_item) ⇒ Object
- #units ⇒ Object
Constructor Details
#initialize(order) ⇒ InventoryUnitBuilder
Returns a new instance of InventoryUnitBuilder.
6 7 8 |
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 6 def initialize(order) @order = order end |
Instance Method Details
#missing_units_for_line_item(line_item) ⇒ Object
16 17 18 19 |
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 16 def missing_units_for_line_item(line_item) quantity = line_item.quantity - line_item.inventory_units.count build_units(line_item, quantity) end |
#units ⇒ Object
10 11 12 13 14 |
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 10 def units @order.line_items.flat_map do |line_item| build_units(line_item, line_item.quantity) end end |