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



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

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



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

def stock_location
  @stock_location
end

Instance Method Details

#split(initial_packages) ⇒ Object



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

def split(initial_packages)
  initial_packages = Array(initial_packages)

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