Class: Reporter::DataSet
- Inherits:
-
Object
- Object
- Reporter::DataSet
- Includes:
- TimeIterator
- Defined in:
- lib/reporter/data_set.rb
Overview
DataSet is where all information about the data for the report comes together.
Instance Attribute Summary collapse
-
#data_source ⇒ Object
Returns the value of attribute data_source.
Instance Method Summary collapse
-
#data_structure(*args) {|@data_structure| ... } ⇒ Object
creation of the definition of the available fields/values to retrieve from the various datasources.
- #get_row(options = {}) ⇒ Object
-
#initialize(*args) {|_self| ... } ⇒ DataSet
constructor
A new instance of DataSet.
-
#iterate(scope, items = nil, &block) ⇒ Object
iterate the chosen scope over a list of selected items.
-
#scope_name(scope) ⇒ Object
returns the name of the current active scope.
Constructor Details
#initialize(*args) {|_self| ... } ⇒ DataSet
Returns a new instance of DataSet.
7 8 9 10 11 12 13 |
# File 'lib/reporter/data_set.rb', line 7 def initialize *args @row_structure = nil @axis_values = {} @row_cache = {} yield self if block_given? end |
Instance Attribute Details
#data_source ⇒ Object
Returns the value of attribute data_source.
20 21 22 |
# File 'lib/reporter/data_set.rb', line 20 def data_source @data_source end |
Instance Method Details
#data_structure(*args) {|@data_structure| ... } ⇒ Object
creation of the definition of the available fields/values to retrieve from the various datasources
23 24 25 26 27 |
# File 'lib/reporter/data_set.rb', line 23 def data_structure *args, &block @data_structure ||= Reporter::DataStructure.new self, *args yield @data_structure if block_given? @data_structure end |
#get_row(options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/reporter/data_set.rb', line 29 def get_row = {} # The datastructure of a resultrow it is a container for caching result values so that # formula's can retrieve values to perform calculations. Queries are executed as late as # possible. This way template caching can eliminate performing database queries altogether. current_scope = data_source.scopes.change().current_scope @row_cache[current_scope.hash] ||= Reporter::ResultRow.new(self, current_scope) end |
#iterate(scope, items = nil, &block) ⇒ Object
iterate the chosen scope over a list of selected items. If no items are provided the defined maximum and minimum limit is used. (scope.set_limit) use iterate_time to iterate over time periods.
40 41 42 43 |
# File 'lib/reporter/data_set.rb', line 40 def iterate scope, items = nil, &block raise "No data-source set" unless data_source data_source.scopes.get(scope).iterate items, self, &block end |
#scope_name(scope) ⇒ Object
returns the name of the current active scope. This can be used to decorate report data with the proper context
46 47 48 49 |
# File 'lib/reporter/data_set.rb', line 46 def scope_name scope raise "No data-source set" unless data_source data_source.scopes.get(scope).human_name end |