Class: Spree::Stock::Adjuster

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

Overview

Used by Prioritizer to adjust item quantities.

See spec/models/spree/stock/prioritizer_spec.rb for use cases.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Adjuster) initialize(inventory_unit, status)

Returns a new instance of Adjuster



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

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

Instance Attribute Details

- (Object) fulfilled

Returns the value of attribute fulfilled



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

def fulfilled
  @fulfilled
end

- (Object) inventory_unit

Returns the value of attribute inventory_unit



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

def inventory_unit
  @inventory_unit
end

- (Object) status

Returns the value of attribute status



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

def status
  @status
end

Instance Method Details

- (Object) adjust(package)



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

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

- (Boolean) fulfilled?

Returns:

  • (Boolean)


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

def fulfilled?
  fulfilled
end