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.
- #units ⇒ Object
Constructor Details
#initialize(order) ⇒ InventoryUnitBuilder
Returns a new instance of InventoryUnitBuilder.
4 5 6 |
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 4 def initialize(order) @order = order end |
Instance Method Details
#units ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 8 def units @order.line_items.map do |line_item| # They go through multiple splits, avoid loading the # association to order until needed. InventoryUnit.new( pending: true, line_item: line_item, variant: line_item.variant, quantity: line_item.quantity, order_id: @order.id ) end end |