Class: Spree::Stock::SplitterChain

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stock_location, splitter_classes = []) ⇒ SplitterChain

Returns a new instance of SplitterChain.



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

def initialize(stock_location, splitter_classes = [])
  @stock_location = stock_location
  @splitter_classes = splitter_classes
end

Instance Attribute Details

#stock_locationObject (readonly)

Returns the value of attribute stock_location.



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

def stock_location
  @stock_location
end

Instance Method Details

#split(initial_packages) ⇒ Object



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

def split(initial_packages)
  initial_packages = Array(initial_packages)

  if @splitter_classes.empty?
    initial_packages
  else
    build_splitter.split(initial_packages)
  end
end