Module: ActiveRecordQueryCounter::ConnectionAdapterExtension

Defined in:
lib/active_record_query_counter.rb

Overview

Module to prepend to the connection adapter to inject the counting behavior.

Instance Method Summary collapse

Instance Method Details

#exec_query(*args) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/active_record_query_counter.rb', line 79

def exec_query(*args)
  start_time = Time.now
  result = super
  if result.is_a?(ActiveRecord::Result)
    ActiveRecordQueryCounter.increment(result.length, Time.now - start_time)
  end
  result
end