class PIM::CalculationFormula
Attributes
block[RW]
calculated_attribute[RW]
dependent_attributes[RW]
Public Class Methods
new()
click to toggle source
# File pim.rb, line 9425 def initialize @calculated_attribute = nil @dependent_attributes = Set.new @block = nil end
Public Instance Methods
calculate(&block)
click to toggle source
# File pim.rb, line 9448 def calculate &block fail 'Calculation block already specified' if @block @block = block @block end
depend_on(*attributes)
click to toggle source
# File pim.rb, line 9443 def depend_on *attributes @dependent_attributes |= symbolized_array(attributes) end
Also aliased as: depends_on
execute(context)
click to toggle source
# File pim.rb, line 9431 def execute context if @block @block.call(context) else fail 'No block specified' end end
target(attribute)
click to toggle source
# File pim.rb, line 9439 def target attribute @calculated_attribute = to_sym(attribute) end