Sha256: b889b41d76a28c6d6db69aecae10183992b0e3e52d5e5e0870bdd688938dc8f7

Contents?: true

Size: 723 Bytes

Versions: 9

Compression:

Stored size: 723 Bytes

Contents

module Neo4j::Aggregate

  # Rules properties on one or more nodes.
  # Can also be used to apply functions (e.g. sum/average) on a set of properties.
  #
  module PropsAggregateMixin
    include Neo4j::NodeMixin
    include Enumerable

    has_list :groups, :counter => true #, :cascade_delete => :incoming

    def init_node(*args)
      @aggregate_id = args[0] unless args.empty?
    end
    
    def aggregate_size
      @aggregator.execute if @aggregator
      groups.size
    end
    
    def each
      @aggregator.execute if @aggregator
      groups.each {|sub_group| sub_group.each {|val| yield val}}
    end

    def aggregate(agg_id)
      @aggregator = PropsAggregator.new(self, agg_id.to_s)
    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/props_aggregate_mixin.rb
neo4j-1.0.0.beta.8 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.7 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.6 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.5 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.4 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.3 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.2 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb
neo4j-1.0.0.beta.1 lib/neo4j.old/extensions/aggregate/props_aggregate_mixin.rb