Module: DbCharmer::ActiveRecord::LogSubscriber

Defined in:
lib/db_charmer/rails3/active_record/log_subscriber.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/db_charmer/rails3/active_record/log_subscriber.rb', line 5

def self.included(base)
  base.send(:attr_accessor, :connection_name)
  base.alias_method_chain :sql, :connection_name
  base.alias_method_chain :debug, :connection_name
end

Instance Method Details

#debug_with_connection_name(msg) ⇒ Object



16
17
18
19
# File 'lib/db_charmer/rails3/active_record/log_subscriber.rb', line 16

def debug_with_connection_name(msg)
  conn = connection_name ? color("  [#{connection_name}]", ActiveSupport::LogSubscriber::BLUE, true) : ''
  debug_without_connection_name(conn + msg)
end

#sql_with_connection_name(event) ⇒ Object



11
12
13
14
# File 'lib/db_charmer/rails3/active_record/log_subscriber.rb', line 11

def sql_with_connection_name(event)
  self.connection_name = event.payload[:connection_name]
  sql_without_connection_name(event)
end