Module: ActiveRecordCalculator::ClassMethods

Defined in:
lib/active_record_calculator.rb

Instance Method Summary collapse

Instance Method Details

#calculator(options = {}) {|c| ... } ⇒ Object

Yields:

  • (c)


17
18
19
20
21
# File 'lib/active_record_calculator.rb', line 17

def calculator(options = {}, &blk)
  c = CalculatorProxy.new(self, options)
  yield c if blk
  c
end

#updater(table, key, options = {}) {|c| ... } ⇒ Object

Yields:

  • (c)


23
24
25
26
27
28
29
30
# File 'lib/active_record_calculator.rb', line 23

def updater(table, key, options = {}, &blk)
  if connection.adapter_name =~ /^sqlite/i
    raise UnsupportedAdapterError, "Updates with the database adapter is not supported."
  end
  c = CalculatorProxy.new(self, options)
  yield c if blk
  UpdaterProxy.new(table, key, c)
end