Class: KPI::Report
- Inherits:
-
Object
show all
- Extended by:
- ActiveSupport::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
Instance Method Summary
collapse
suppress_memoization, suppressed_memoization?
included
Constructor Details
#initialize(*args) ⇒ Report
Returns a new instance of Report.
10
11
12
13
|
# File 'app/models/kpi/report.rb', line 10
def initialize(*args)
@options = args.
@time = @options[:time] || Time.now
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
41
42
43
44
45
|
# File 'app/models/kpi/report.rb', line 41
def method_missing(name, *args)
return kpi_exists?($1.to_sym) if (/(.*)\?/ =~ name.to_s)
super
end
|
Instance Attribute Details
#time ⇒ Object
Returns the value of attribute time.
14
15
16
|
# File 'app/models/kpi/report.rb', line 14
def time
@time
end
|
Instance Method Details
#collect! ⇒ Object
16
17
18
19
|
# File 'app/models/kpi/report.rb', line 16
def collect!
self.defined_kpis.each {|kpi_method| send(kpi_method) }
self
end
|
#defined_kpis ⇒ Object
33
34
35
|
# File 'app/models/kpi/report.rb', line 33
def defined_kpis
self.class.defined_kpis.map(&:to_sym)
end
|
#entries ⇒ Object
21
22
23
24
25
26
27
|
# File 'app/models/kpi/report.rb', line 21
def entries
Enumerator.new do |yielder|
self.class.defined_kpis.each do |kpi_method|
yielder.yield(send(kpi_method))
end
end
end
|
#result(*args) ⇒ Object
37
38
39
|
# File 'app/models/kpi/report.rb', line 37
def result(*args)
KPI::Entry.new *args
end
|
#title ⇒ Object
29
30
31
|
# File 'app/models/kpi/report.rb', line 29
def title
self.class.name
end
|