Sha256: 3b7751d2a4f19b6f20e487e8d06b8dcfe16d11324e8aa19375cca199e137b36b
Contents?: true
Size: 1.06 KB
Versions: 22
Compression:
Stored size: 1.06 KB
Contents
module Spree module Stock class ContentItem attr_accessor :inventory_unit, :state def initialize(inventory_unit, state = :on_hand) @inventory_unit = inventory_unit @state = state end with_options allow_nil: true do delegate :line_item, :quantity, :variant, to: :inventory_unit delegate :price, to: :line_item delegate :dimension, :volume, :weight, to: :variant, prefix: true end def splittable_by_weight? quantity > 1 && variant_weight.present? end def weight variant_weight * quantity end def quantity=(value) @inventory_unit.quantity = value end def on_hand? state.to_s == 'on_hand' end def backordered? state.to_s == 'backordered' end def amount price * quantity end def volume variant_volume * quantity end def dimension variant_dimension * quantity end end end end
Version data entries
22 entries across 22 versions & 1 rubygems