Class: KPI::Report
- Inherits:
-
Object
- Object
- KPI::Report
- Extended by:
- Memoizable, SuppressMemoization
- Includes:
- DynamicDefinitions
- Defined in:
- app/models/kpi/report.rb,
app/models/kpi/report/dynamic_definitions.rb,
app/models/kpi/report/suppress_memoization.rb
Defined Under Namespace
Modules: DynamicDefinitions, SuppressMemoization
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #collect! ⇒ Object
- #defined_kpis ⇒ Object
- #entries ⇒ Object
-
#initialize(*args) ⇒ Report
constructor
A new instance of Report.
- #method_missing(name, *args) ⇒ Object
- #result(*args) ⇒ Object
Methods included from SuppressMemoization
suppress_memoization, suppressed_memoization?
Methods included from Memoizable
Methods included from DynamicDefinitions
Constructor Details
#initialize(*args) ⇒ Report
Returns a new instance of Report.
10 11 12 13 14 |
# File 'app/models/kpi/report.rb', line 10 def initialize(*args) @options = args. @time = @options[:time] || Time.now @title = @options[:title] || self.class.name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
38 39 40 41 42 |
# File 'app/models/kpi/report.rb', line 38 def method_missing(name, *args) # check if KPI exists in report if name of missing method has trailing '?' return kpi_exists?($1.to_sym) if (/(.*)\?/ =~ name.to_s) super end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
15 16 17 |
# File 'app/models/kpi/report.rb', line 15 def time @time end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
15 16 17 |
# File 'app/models/kpi/report.rb', line 15 def title @title end |
Instance Method Details
#collect! ⇒ Object
17 18 19 20 |
# File 'app/models/kpi/report.rb', line 17 def collect! self.defined_kpis.each {|kpi_method| send(kpi_method) } self end |
#defined_kpis ⇒ Object
30 31 32 |
# File 'app/models/kpi/report.rb', line 30 def defined_kpis self.class.defined_kpis.map(&:to_sym) end |
#entries ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/kpi/report.rb', line 22 def entries Enumerator.new do |yielder| self.class.defined_kpis.each do |kpi_method| yielder.yield(send(kpi_method)) end end end |