Sha256: dd52ad522d313339ba18859b4e408575bfc450e34081c4c08d7aeb03d55154de

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

module Neo4j::Aggregate

# This is the group node. When a new aggregate group is created it will be of this type.
# Includes the Enumerable mixin in order to iterator over each node member in the group.
# Overrides [] and []= properties, so that we can access aggregated properties or relationships.
#
# :api: private
  class NodeGroup #:nodoc:
    include Neo4j::NodeMixin
    include Enumerable

    property :aggregate_group, :aggregate_size

    def self.create(aggregate_group)
      new_node = NodeGroup.new
      new_node.aggregate_group = aggregate_group.kind_of?(Symbol)? aggregate_group.to_s : aggregate_group
      new_node.aggregate_size = 0
      new_node
    end

    def each
      rels.outgoing.nodes.each { |n| yield n }
    end

    # :api: private
    def [](key)
      value = super(key)
      return value unless value.nil?

      sub_group = rels.outgoing(key).nodes.first
      return sub_group unless sub_group.nil?

      # traverse all sub nodes and get their properties
      PropertyEnum.new(rels.outgoing.nodes, key)
    end

#    def []=(key, value)
#      super key, value
#      self.get_property(key)
#    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
neo4j-1.0.0.beta.9 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.8 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.7 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.6 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.5 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.4 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.3 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.2 lib/neo4j.old/extensions/aggregate/node_group.rb
neo4j-1.0.0.beta.1 lib/neo4j.old/extensions/aggregate/node_group.rb