class PIM::CalculationFormula

Attributes

block[RW]
calculated_attribute[RW]
dependent_attributes[RW]

Public Class Methods

new() click to toggle source
# File pim.rb, line 8986
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 9009
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 9004
def depend_on *attributes
  @dependent_attributes |= symbolized_array(attributes)
end
Also aliased as: depends_on
depends_on(*attributes)
Alias for: depend_on
execute(context) click to toggle source
# File pim.rb, line 8992
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 9000
def target attribute
  @calculated_attribute = to_sym(attribute)
end