Class: Spree::Stock::ContentItem Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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_unitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def inventory_unit
  @inventory_unit
end

#stateObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def state
  @state
end

Instance Method Details

#amountObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
# File 'app/models/spree/stock/content_item.rb', line 35

def amount
  price * quantity
end

#backordered?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


27
28
29
# File 'app/models/spree/stock/content_item.rb', line 27

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

#line_itemObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'app/models/spree/stock/content_item.rb', line 19

def line_item
  inventory_unit.line_item
end

#on_hand?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


23
24
25
# File 'app/models/spree/stock/content_item.rb', line 23

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

#priceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'app/models/spree/stock/content_item.rb', line 31

def price
  variant.price
end

#quantityObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

#variantObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'app/models/spree/stock/content_item.rb', line 11

def variant
  inventory_unit.variant
end

#weightObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'app/models/spree/stock/content_item.rb', line 15

def weight
  variant.weight * quantity
end