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=(value) ⇒ Object
- #splittable_by_weight? ⇒ Boolean
- #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
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 |
#dimension ⇒ Object
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 |
#volume ⇒ Object
45 46 47 |
# File 'app/models/spree/stock/content_item.rb', line 45 def volume variant_volume * quantity end |
#weight ⇒ Object
25 26 27 |
# File 'app/models/spree/stock/content_item.rb', line 25 def weight variant_weight * quantity end |