Class: Spree::Stock::ContentItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inventory_unit, state = :on_hand) ⇒ ContentItem


6
7
8
9
# File 'app/models/spree/stock/content_item.rb', line 6

def initialize(inventory_unit, state = :on_hand)
  @inventory_unit = inventory_unit
  @state = state
end

Instance Attribute Details

#inventory_unitObject

Returns the value of attribute inventory_unit


4
5
6
# File 'app/models/spree/stock/content_item.rb', line 4

def inventory_unit
  @inventory_unit
end

#stateObject

Returns the value of attribute state


4
5
6
# File 'app/models/spree/stock/content_item.rb', line 4

def state
  @state
end

Instance Method Details

#amountObject


41
42
43
# File 'app/models/spree/stock/content_item.rb', line 41

def amount
  price * quantity
end

#backordered?Boolean


37
38
39
# File 'app/models/spree/stock/content_item.rb', line 37

def backordered?
  state.to_s == 'backordered'
end

#dimensionObject


49
50
51
# File 'app/models/spree/stock/content_item.rb', line 49

def dimension
  variant_dimension * quantity
end

#on_hand?Boolean


33
34
35
# File 'app/models/spree/stock/content_item.rb', line 33

def on_hand?
  state.to_s == 'on_hand'
end

#quantity=(value) ⇒ Object


29
30
31
# File 'app/models/spree/stock/content_item.rb', line 29

def quantity=(value)
  @inventory_unit.quantity = value
end

#splittable_by_weight?Boolean


21
22
23
# File 'app/models/spree/stock/content_item.rb', line 21

def splittable_by_weight?
  quantity > 1 && variant_weight.present?
end

#volumeObject


45
46
47
# File 'app/models/spree/stock/content_item.rb', line 45

def volume
  variant_volume * quantity
end

#weightObject


25
26
27
# File 'app/models/spree/stock/content_item.rb', line 25

def weight
  variant_weight * quantity
end