Class: Wonkavision::Analytics::Persistence::Store
- Inherits:
-
Object
- Object
- Wonkavision::Analytics::Persistence::Store
- Defined in:
- lib/wonkavision/plugins/analytics/persistence/store.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_facts(data) ⇒ Object
returns the current value of the facts record.
-
#execute_query(query) ⇒ Object
Aggregations persistence support.
-
#initialize(owner) ⇒ Store
constructor
A new instance of Store.
-
#remove_facts(data) ⇒ Object
returns the previous value of the facts record.
- #update_aggregation(aggregation_data) ⇒ Object
-
#update_facts(data) ⇒ Object
Facts persistence support.
Constructor Details
#initialize(owner) ⇒ Store
Returns a new instance of Store.
22 23 24 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 22 def initialize(owner) @owner = owner end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
21 22 23 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 21 def owner @owner end |
Class Method Details
.[](store_name) ⇒ Object
6 7 8 9 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 6 def self.[](store_name) @stores ||= {} @stores[store_name.to_s] end |
.[]=(store_name, store) ⇒ Object
11 12 13 14 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 11 def self.[]=(store_name,store) @stores ||= {} @stores[store_name.to_s] = store end |
.inherited(store) ⇒ Object
16 17 18 19 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 16 def self.inherited(store) store_name = store.name.split("::").pop.underscore self[store_name] = store end |
Instance Method Details
#add_facts(data) ⇒ Object
returns the current value of the facts record
38 39 40 41 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 38 def add_facts(data) record_id = assert_record_id(data) insert_facts_record record_id, data end |
#execute_query(query) ⇒ Object
Aggregations persistence support
Takes a Wonkavision::Analytics::Query and returns an array of matching tuples
53 54 55 56 57 58 59 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 53 def execute_query(query) dimension_names = query.all_dimensions? ? [] : query.referenced_dimensions.sort{ |a,b| a.to_s <=> b.to_s } fetch_tuples(dimension_names, query.filters) end |
#remove_facts(data) ⇒ Object
returns the previous value of the facts record
44 45 46 47 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 44 def remove_facts(data) record_id = assert_record_id(data) delete_facts_record record_id, data end |
#update_aggregation(aggregation_data) ⇒ Object
61 62 63 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 61 def update_aggregation(aggregation_data) update_tuple(aggregation_data) end |
#update_facts(data) ⇒ Object
Facts persistence support
returns a two element array, the first element containing the prior state of the facts record, the second element containing the current state of the facts record
32 33 34 35 |
# File 'lib/wonkavision/plugins/analytics/persistence/store.rb', line 32 def update_facts(data) record_id = assert_record_id(data) update_facts_record record_id, data end |