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

- (ContentItem) initialize(inventory_unit, state = :on_hand)

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

- (Object) inventory_unit

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

- (Object) state

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

- (Object) amount

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

- (Boolean) backordered?

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

- (Object) line_item

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

- (Boolean) on_hand?

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

- (Object) price

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

- (Object) quantity

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

- (Object) variant

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

- (Object) weight

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