Sha256: 4ebd86bf3e5e306b09a386ce65b7044a1f5fbb942003a020a685aa8e554a58aa
Contents?: true
Size: 1.13 KB
Versions: 32
Compression:
Stored size: 1.13 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, :variant, to: :inventory_unit delegate :price, to: :variant delegate :dimension, :volume, :weight, to: :variant, prefix: true end def weight variant_weight * quantity end def on_hand? state.to_s == "on_hand" end def backordered? state.to_s == "backordered" end def amount price * quantity end def quantity # Since inventory units don't have a quantity, # make this always 1 for now, leaving ourselves # open to a different possibility in the future, # but this massively simplifies things for now 1 end def volume variant_volume * quantity end def dimension variant_dimension * quantity end end end end
Version data entries
32 entries across 32 versions & 1 rubygems