Class: Spree::Stock::Adjuster

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inventory_unit, status) ⇒ Adjuster

Returns a new instance of Adjuster.



8
9
10
11
12
# File 'app/models/spree/stock/adjuster.rb', line 8

def initialize(inventory_unit, status)
  @inventory_unit = inventory_unit
  @status = status
  @fulfilled = false
end

Instance Attribute Details

#fulfilledObject

Returns the value of attribute fulfilled.



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

def fulfilled
  @fulfilled
end

#inventory_unitObject

Returns the value of attribute inventory_unit.



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

def inventory_unit
  @inventory_unit
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#adjust(package) ⇒ Object



14
15
16
17
18
19
20
# File 'app/models/spree/stock/adjuster.rb', line 14

def adjust(package)
  if fulfilled?
    package.remove(inventory_unit)
  else
    self.fulfilled = true
  end
end

#fulfilled?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/spree/stock/adjuster.rb', line 22

def fulfilled?
  fulfilled
end