Sha256: e99ffb2801875e7de6b5291d88016560bd18b3d0b001241f9b534bb619bc74b9

Contents?: true

Size: 1.17 KB

Versions: 20

Compression:

Stored size: 1.17 KB

Contents

module Neo4j
  module Wrapper
    module Rule
      module Functions

        # A function for counting number of nodes of a given class.
        class Size < Function
          def initialize
            @property = '_classname'
            @@lock ||= Java::java.lang.Object.new
          end

          def calculate?(changed_property)
            true
          end

          def delete(rule_name, rule_node, _)
            key = rule_node_property(rule_name)
            rule_node[key] ||= 0
            rule_node[key] -= 1
          end

          def add(rule_name, rule_node, _)
            key = rule_node_property(rule_name)
            rule_node[key] ||= 0
            rule_node[key] += 1
          end

          def update(*)
            # we are only counting, not interested in property changes
          end

          def classes_changed(rule_name, rule_node, class_change)
            key = rule_node_property(rule_name)
            @@lock.synchronized do
              rule_node[key] ||= 0
              rule_node[key] += class_change.net_change
            end
          end

          def self.function_name
            :size
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
neo4j-wrapper-2.3.0-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.2.4-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.2.3-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.2.1-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.2.0-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.2.0.rc1-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.1.0-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.0.1-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.0.0-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.0.0.rc2-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-2.0.0.rc1-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.11-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.10-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.9-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.8-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.7-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.6-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.5-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.4-java lib/neo4j-wrapper/rule/functions/size.rb
neo4j-wrapper-0.0.3-java lib/neo4j-wrapper/rule/functions/size.rb