Class: Neo4j::Wrapper::Rule::Functions::Sum

Inherits:
Function
  • Object
show all
Defined in:
lib/neo4j-wrapper/rule/functions/sum.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Function

#add, #calculate?, #delete, #function_id, #initialize, rule_node_property, #rule_node_property, #to_s, #value

Constructor Details

This class inherits a constructor from Neo4j::Wrapper::Rule::Functions::Function

Class Method Details

.function_nameObject



22
23
24
# File 'lib/neo4j-wrapper/rule/functions/sum.rb', line 22

def self.function_name
  :sum
end

Instance Method Details

#update(rule_name, rule_node, old_value, new_value) ⇒ Object

Updates the function’s value. Called after the transactions commits and a property has been changed on a node.

Arguments

  • rule_name

    the name of the rule group

  • rule_node

    the node which contains the value of this function

  • old_value new value

    the changed value of the property (when the transaction commits)



14
15
16
17
18
19
20
# File 'lib/neo4j-wrapper/rule/functions/sum.rb', line 14

def update(rule_name, rule_node, old_value, new_value)
  key = rule_node_property(rule_name)
  rule_node[key] ||= 0
  old_value ||= 0
  new_value ||= 0
  rule_node[key] += new_value - old_value
end