Module: Wonkavision::Plugins::Aggregation::ClassMethods
- Defined in:
- lib/wonkavision/plugins/analytics/aggregation.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
77
78
79
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 77
def method_missing(m,*args,&block)
aggregation_spec.respond_to?(m) ? aggregation_spec.send(m,*args,&block) : super
end
|
Instance Method Details
#[](dimensions) ⇒ Object
37
38
39
40
41
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 37
def [](dimensions)
key = [dimension_names(dimensions),dimension_keys(dimensions)]
@instances ||= HashWithIndifferentAccess.new
@instances[key] ||= self.new(dimensions)
end
|
#aggregates(facts_class = nil) ⇒ Object
Also known as:
facts
43
44
45
46
47
48
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 43
def aggregates(facts_class = nil)
return aggregation_options[:facts_class] unless facts_class
facts_class.aggregations << self
aggregation_options[:facts_class] = facts_class
end
|
#dimension_keys(dimensions) ⇒ Object
55
56
57
58
59
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 55
def dimension_keys(dimensions)
dimension_names(dimensions).map do |dim|
dimensions[dim][self.dimensions[dim].key.to_s]
end
end
|
#dimension_names(dimensions) ⇒ Object
51
52
53
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 51
def dimension_names(dimensions)
dimensions.keys.sort
end
|
#query(options = {}, &block) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 61
def query(options={},&block)
raise "Aggregation#query is not valid unless a store has been configured" unless store
query = Wonkavision::Analytics::Query.new
query.instance_eval(&block) if block
query.validate!
return query if options[:defer]
tuples = store.execute_query(query)
Wonkavision::Analytics::CellSet.new( self,
query,
tuples )
end
|
#store(new_store = nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/wonkavision/plugins/analytics/aggregation.rb', line 21
def store(new_store=nil)
if new_store
store = new_store.kind_of?(Wonkavision::Analytics::Persistence::Store) ? store :
Wonkavision::Analytics::Persistence::Store[new_store]
raise "Could not find a storage type of #{new_store}" unless store
store = store.new(self) if store.respond_to?(:new)
aggregation_options[:store] = store
else
aggregation_options[:store]
end
end
|