Sha256: db4b79b3682308490a496cd59331acc0935392977e28fe146112e8860fd1fdcc

Contents?: true

Size: 484 Bytes

Versions: 13

Compression:

Stored size: 484 Bytes

Contents

module Spree
  module Stock
    class InventoryUnitBuilder
      def initialize(order)
        @order = order
      end

      def units
        @order.line_items.flat_map do |line_item|
          line_item.quantity.times.map do |i|
            @order.inventory_units.build(
              pending: true,
              variant_id: line_item.variant_id,
              line_item: line_item,
              order: @order
            )
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spree_core-3.2.9 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.8 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.7 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.6 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.5 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.4 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.3 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.2 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.1 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.0 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.0.rc3 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.0.rc2 app/models/spree/stock/inventory_unit_builder.rb
spree_core-3.2.0.rc1 app/models/spree/stock/inventory_unit_builder.rb