Sha256: 8f82a6539108e82b9350bef64cc0b642fe95603e734efa422cd4ce4cb2f7561f

Contents?: true

Size: 449 Bytes

Versions: 6

Compression:

Stored size: 449 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: line_item.variant,
              line_item: line_item
            )
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_core-2.4.2 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.1 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.0 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.0.rc3 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.0.rc2 app/models/spree/stock/inventory_unit_builder.rb
spree_core-2.4.0.rc1 app/models/spree/stock/inventory_unit_builder.rb