Class: ClarkKent::ReportColumn
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ClarkKent::ReportColumn
show all
- Includes:
- Cloneable
- Defined in:
- app/models/clark_kent/report_column.rb
Constant Summary
collapse
- SummaryMethods =
['total','average']
Instance Method Summary
collapse
Methods included from Cloneable
#cloneable_attributes, #reset_timestamps
Instance Method Details
#calculate_summary(values) ⇒ Object
21
22
23
24
|
# File 'app/models/clark_kent/report_column.rb', line 21
def calculate_summary(values)
return nil unless self.summary_method.present?
calculator.new(values).calculate
end
|
#calculator ⇒ Object
34
35
36
|
# File 'app/models/clark_kent/report_column.rb', line 34
def calculator
('ClarkKent::' + summary_method.camelcase + 'Calculator').constantize
end
|
#config_options ⇒ Object
42
43
44
|
# File 'app/models/clark_kent/report_column.rb', line 42
def config_options
report.column_options_for(self.name.to_sym)
end
|
#has_options? ⇒ Boolean
13
14
15
|
# File 'app/models/clark_kent/report_column.rb', line 13
def has_options?
config_options.present?
end
|
#link ⇒ Object
46
47
48
|
# File 'app/models/clark_kent/report_column.rb', line 46
def link
config_options.link
end
|
#name ⇒ Object
38
39
40
|
# File 'app/models/clark_kent/report_column.rb', line 38
def name
column_name
end
|
#report_sort_pretty ⇒ Object
17
18
19
|
# File 'app/models/clark_kent/report_column.rb', line 17
def report_sort_pretty
{'ascending' => 'A->Z','descending' => 'Z->A'}[self.report_sort]
end
|
#sortable? ⇒ Boolean
30
31
32
|
# File 'app/models/clark_kent/report_column.rb', line 30
def sortable?
config_options.order_sql.present?
end
|
#summarizable? ⇒ Boolean
26
27
28
|
# File 'app/models/clark_kent/report_column.rb', line 26
def summarizable?
config_options.summarizable
end
|
54
55
56
|
# File 'app/models/clark_kent/report_column.rb', line 54
def time_format
config_options.time_format
end
|
#time_zone_column ⇒ Object
50
51
52
|
# File 'app/models/clark_kent/report_column.rb', line 50
def time_zone_column
config_options.time_zone_column
end
|