Module: OlapReport::Cube::Aggregation

Defined in:
lib/olap_report/cube/aggregation.rb

Defined Under Namespace

Classes: Table

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aggregationsObject (readonly)

Returns the value of attribute aggregations.



4
5
6
# File 'lib/olap_report/cube/aggregation.rb', line 4

def aggregations
  @aggregations
end

Class Method Details

.extended(base) ⇒ Object



6
7
8
# File 'lib/olap_report/cube/aggregation.rb', line 6

def self.extended(base)
  base.instance_variable_set(:@aggregations, [])
end

Instance Method Details

#aggregate!Object



16
17
18
# File 'lib/olap_report/cube/aggregation.rb', line 16

def aggregate!
  aggregations.each(&:aggregate_table!)
end

#aggregation(levels) ⇒ Object



24
25
26
27
28
29
# File 'lib/olap_report/cube/aggregation.rb', line 24

def aggregation(levels)
  aggregations.find do |a|
    levels_def = a.levels.each_with_object({}){|level,acc| acc[level.dimension_name] = level.name}
    levels_def == levels
  end
end

#define_aggregation(levels) ⇒ Object



10
11
12
13
14
# File 'lib/olap_report/cube/aggregation.rb', line 10

def define_aggregation(levels)
  table = Table.new(self, levels)
  raise OlapReport::Cube::DuplicateAggregationError if aggregations.include?(table)
  @aggregations << table
end

#update!Object



20
21
22
# File 'lib/olap_report/cube/aggregation.rb', line 20

def update!
  aggregations.each(&:update!)
end