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



135
136
137
138
139
140
141
142
# File 'lib/active_record_query_counter.rb', line 135

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