Class: Devrobber::ActiveRecord::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/devrobber/active_record.rb

Instance Method Summary collapse

Instance Method Details

#sql(event) ⇒ Object



5
6
7
8
# File 'lib/devrobber/active_record.rb', line 5

def sql(event)
  sql = event.payload[:sql].sub(/(\s*WHERE.*|;)$/,"")
  sqls[sql] += 1
end

#sqlsObject



10
11
12
# File 'lib/devrobber/active_record.rb', line 10

def sqls
  Thread.current[:devrobber_sql] ||= Hash.new(0)
end