Class: Spree::Stock::InventoryUnitBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/stock/inventory_unit_builder.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary (collapse)

Constructor Details

- (InventoryUnitBuilder) initialize(order)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

- (Object) units

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/models/spree/stock/inventory_unit_builder.rb', line 8

def units
  @order.line_items.flat_map do |line_item|
    Array.new(line_item.quantity) do
      Spree::InventoryUnit.new(
        pending: true,
        variant: line_item.variant,
        line_item: line_item,
        order: @order
      )
    end
  end
end