Class: Wongi::Engine::DSL::Clause::Aggregate

Inherits:
Object
  • Object
show all
Defined in:
lib/wongi-engine/dsl/clause/aggregate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var, options = {}) ⇒ Aggregate

Returns a new instance of Aggregate.



6
7
8
9
10
11
12
13
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 6

def initialize(var, options = {})
  @var = var
  @over = options[:over]
  @partition = Array(options[:partition])
  @aggregate = options[:using]
  @map = options[:map]
  raise "can only partition by variables" unless partition.all? { |p| Template.variable?(p) }
end

Instance Attribute Details

#aggregateObject (readonly)

Returns the value of attribute aggregate.



4
5
6
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 4

def aggregate
  @aggregate
end

#mapObject (readonly)

Returns the value of attribute map.



4
5
6
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 4

def map
  @map
end

#overObject (readonly)

Returns the value of attribute over.



4
5
6
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 4

def over
  @over
end

#partitionObject (readonly)

Returns the value of attribute partition.



4
5
6
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 4

def partition
  @partition
end

#varObject (readonly)

Returns the value of attribute var.



4
5
6
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 4

def var
  @var
end

Instance Method Details

#compile(context) ⇒ Object



15
16
17
# File 'lib/wongi-engine/dsl/clause/aggregate.rb', line 15

def compile(context)
  context.tap { |c| c.aggregate_node(var, over, partition, aggregate, map) }
end