Class: ActiveMetric::Report
- Inherits:
-
Object
- Object
- ActiveMetric::Report
show all
- Includes:
- Mongoid::Document
- Defined in:
- lib/active_metric/report.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
45
46
47
48
49
|
# File 'lib/active_metric/report.rb', line 45
def method_missing(method, *args)
subject_class = subject_class_for_report(method)
subject_class ? subject_class.where(report_id: id).all :
super(method, *args)
end
|
Instance Method Details
#min ⇒ Object
27
28
29
|
# File 'lib/active_metric/report.rb', line 27
def min
0
end
|
#name ⇒ Object
11
12
13
|
# File 'lib/active_metric/report.rb', line 11
def name
"report"
end
|
#save_display_name ⇒ Object
15
16
17
|
# File 'lib/active_metric/report.rb', line 15
def save_display_name
self.display_name ||= set_display_name
end
|
#series ⇒ Object
23
24
25
|
# File 'lib/active_metric/report.rb', line 23
def series
subjects.map(&:series).flatten
end
|
#set_display_name ⇒ Object
19
20
21
|
# File 'lib/active_metric/report.rb', line 19
def set_display_name
"Report"
end
|
#subject_class_for_report(method) ⇒ Object
51
52
53
54
|
# File 'lib/active_metric/report.rb', line 51
def subject_class_for_report(method)
return "#{self.class.parent}::#{method.to_s.classify}".constantize if method.to_s.match /subjects$/
rescue NameError
end
|
#subjects_by_type ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/active_metric/report.rb', line 35
def subjects_by_type
subjects_type = {}
subjects.each do |subject|
type = subject.class.name.split("::").last.underscore
subjects_type[type] ||= []
subjects_type[type] << subject
end
subjects_type
end
|
#view_model ⇒ Object
31
32
33
|
# File 'lib/active_metric/report.rb', line 31
def view_model
nil
end
|