Class: ActiveReporter::Aggregator::Base
- Inherits:
-
Object
- Object
- ActiveReporter::Aggregator::Base
- Defined in:
- lib/active_reporter/aggregator/base.rb
Direct Known Subclasses
Array, Average, Count, Max, Min, Ratio, Sum, Calculator::Base, Tracker::Base
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Instance Method Summary collapse
- #aggregate(groups) ⇒ Object
- #default_value ⇒ Object
-
#initialize(name, report, options = {}) ⇒ Base
constructor
A new instance of Base.
- #sql_value_name ⇒ Object
Constructor Details
#initialize(name, report, options = {}) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/active_reporter/aggregator/base.rb', line 8 def initialize(name, report, = {}) @name = name @report = report @options = validate_params! end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/active_reporter/aggregator/base.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/active_reporter/aggregator/base.rb', line 6 def @options end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
6 7 8 |
# File 'lib/active_reporter/aggregator/base.rb', line 6 def report @report end |
Instance Method Details
#aggregate(groups) ⇒ Object
23 24 25 |
# File 'lib/active_reporter/aggregator/base.rb', line 23 def aggregate(groups) relate(groups).select("#{function} AS #{sql_value_name}") end |
#default_value ⇒ Object
19 20 21 |
# File 'lib/active_reporter/aggregator/base.rb', line 19 def default_value .fetch(:default_value, nil) end |
#sql_value_name ⇒ Object
15 16 17 |
# File 'lib/active_reporter/aggregator/base.rb', line 15 def sql_value_name "_report_aggregator_#{name}" end |