Class: Spree::Stock::Differentiator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, packages) ⇒ Differentiator

Returns a new instance of Differentiator



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

def initialize(order, packages)
  @order = order
  @packages = packages
  build_packed
  build_required
  build_missing
end

Instance Attribute Details

#missingObject (readonly)

Returns the value of attribute missing



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

def missing
  @missing
end

#orderObject (readonly)

Returns the value of attribute order



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

def order
  @order
end

#packagesObject (readonly)

Returns the value of attribute packages



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

def packages
  @packages
end

#packedObject (readonly)

Returns the value of attribute packed



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

def packed
  @packed
end

#requiredObject (readonly)

Returns the value of attribute required



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

def required
  @required
end

Instance Method Details

#missing?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/spree/stock/differentiator.rb', line 14

def missing?
  missing.values.any? { |v| v > 0 }
end