Class: ActiveRecordCalculator::UpdaterProxy
- Inherits:
-
Object
- Object
- ActiveRecordCalculator::UpdaterProxy
- Defined in:
- lib/active_record_calculator/updater_proxy.rb
Instance Method Summary collapse
- #avg(column_name, as, options = {}) ⇒ Object (also: #average)
- #cnt(column_name, as, options = {}) ⇒ Object (also: #count)
- #col(column_name, as = nil) ⇒ Object (also: #column)
-
#initialize(table, foreign_key, calculator_proxy) ⇒ UpdaterProxy
constructor
A new instance of UpdaterProxy.
- #max(column_name, as, options = {}) ⇒ Object (also: #maximum)
- #min(column_name, as, options = {}) ⇒ Object (also: #minimum)
- #statement ⇒ Object
- #sum(column_name, as, options = {}) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(table, foreign_key, calculator_proxy) ⇒ UpdaterProxy
Returns a new instance of UpdaterProxy.
3 4 5 6 7 8 9 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 3 def initialize(table, foreign_key, calculator_proxy) @table = table set_calculator(calculator_proxy) @key = foreign_key valid_columns? valid_update_key? end |
Instance Method Details
#avg(column_name, as, options = {}) ⇒ Object Also known as: average
37 38 39 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 37 def avg(column_name, as, = {}) calculator.avg(column_name, as, ) end |
#cnt(column_name, as, options = {}) ⇒ Object Also known as: count
28 29 30 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 28 def cnt(column_name, as, = {}) calculator.count(column_name, as, ) end |
#col(column_name, as = nil) ⇒ Object Also known as: column
23 24 25 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 23 def col(column_name, as = nil) calculator.col(column_name, as) end |
#max(column_name, as, options = {}) ⇒ Object Also known as: maximum
42 43 44 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 42 def max(column_name, as, = {}) calculator.max(column_name, as, ) end |
#min(column_name, as, options = {}) ⇒ Object Also known as: minimum
47 48 49 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 47 def min(column_name, as, = {}) calculator.min(column_name, as, ) end |
#statement ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 11 def statement case connection.adapter_name when /mysql/i then mysql_statement when /postgresql/i then psql_statement else abstract_statement end end |
#sum(column_name, as, options = {}) ⇒ Object
33 34 35 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 33 def sum(column_name, as, = {}) calculator.sum(column_name, as, ) end |
#update ⇒ Object
19 20 21 |
# File 'lib/active_record_calculator/updater_proxy.rb', line 19 def update connection.update(statement) end |