Class: ReportTemplate
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ReportTemplate
show all
- Defined in:
- app/models/report_template.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/models/report_template.rb', line 46
def method_missing(name, *args, &block)
return super unless name.to_s.starts_with?('condition_')
self.conditions ||= {}
name = name.to_s.gsub('condition_', '')
if name[-1] == '='
name = name[0, name.length-1]
self.conditions[name] = (args[0].is_a?(Array) ? args[0].select{|x| !x.blank?} : args[0])
else
self.conditions[name]
end
end
|
Instance Attribute Details
#report_builder_instance ⇒ Object
Returns the value of attribute report_builder_instance.
3
4
5
|
# File 'app/models/report_template.rb', line 3
def report_builder_instance
@report_builder_instance
end
|
Instance Method Details
#human_calculation_name(field) ⇒ Object
64
65
66
|
# File 'app/models/report_template.rb', line 64
def human_calculation_name(field)
report_builder.human_calculation_name field
end
|
#human_condition_name(field) ⇒ Object
68
69
70
|
# File 'app/models/report_template.rb', line 68
def human_condition_name(field)
report_builder.human_condition_name field
end
|
#human_condition_values(condition) ⇒ Object
82
83
84
85
86
87
88
89
90
|
# File 'app/models/report_template.rb', line 82
def human_condition_values(condition)
return nil if conditions[condition].blank?
values = conditions[condition].map do |v|
report_builder.human_condition_values(condition)[v]
end
values.join(', ')
end
|
#human_field_name(field) ⇒ Object
60
61
62
|
# File 'app/models/report_template.rb', line 60
def human_field_name(field)
report_builder.human_field_name field
end
|
#human_groupping_name ⇒ Object
72
73
74
75
|
# File 'app/models/report_template.rb', line 72
def human_groupping_name
return nil if groupping.blank?
human_field_name groupping
end
|
#human_sorting_name ⇒ Object
77
78
79
80
|
# File 'app/models/report_template.rb', line 77
def human_sorting_name
return nil if sorting.blank?
human_field_name sorting
end
|
#report_builder(report = nil) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/models/report_template.rb', line 32
def report_builder(report=nil)
return report_builder_instance unless report_builder_instance.nil?
report_builder_instance = ReportBuilder.constantize(kind)
report_builder_instance = report_builder_instance.new(report) if report_builder_instance
return report_builder_instance
end
|
#respond_to?(key, include_private = false) ⇒ Boolean
41
42
43
44
|
# File 'app/models/report_template.rb', line 41
def respond_to?(key, include_private=false)
return true if key.to_s.starts_with?('condition_')
super(key, include_private)
end
|