Class: Spree::Stock::ContentItem
- Inherits:
-
Object
- Object
- Spree::Stock::ContentItem
- Defined in:
- app/models/spree/stock/content_item.rb
Instance Attribute Summary collapse
-
#inventory_unit ⇒ Object
Returns the value of attribute inventory_unit.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #amount ⇒ Object
- #backordered? ⇒ Boolean
- #dimension ⇒ Object
-
#initialize(inventory_unit, state = :on_hand) ⇒ ContentItem
constructor
A new instance of ContentItem.
- #on_hand? ⇒ Boolean
- #quantity ⇒ Object
- #volume ⇒ Object
- #weight ⇒ Object
Constructor Details
#initialize(inventory_unit, state = :on_hand) ⇒ ContentItem
Returns a new instance of 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_unit ⇒ Object
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 |
#state ⇒ Object
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
#amount ⇒ Object
33 34 35 |
# File 'app/models/spree/stock/content_item.rb', line 33 def amount price * quantity end |
#backordered? ⇒ Boolean
28 29 30 |
# File 'app/models/spree/stock/content_item.rb', line 28 def backordered? state.to_s == "backordered" end |
#dimension ⇒ Object
49 50 51 |
# File 'app/models/spree/stock/content_item.rb', line 49 def dimension variant_dimension * quantity end |
#on_hand? ⇒ Boolean
24 25 26 |
# File 'app/models/spree/stock/content_item.rb', line 24 def on_hand? state.to_s == "on_hand" end |
#quantity ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/models/spree/stock/content_item.rb', line 37 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 |
#volume ⇒ Object
45 46 47 |
# File 'app/models/spree/stock/content_item.rb', line 45 def volume variant_volume * quantity end |
#weight ⇒ Object
20 21 22 |
# File 'app/models/spree/stock/content_item.rb', line 20 def weight variant_weight * quantity end |