2010-11-05 05:28:52 +00:00
|
|
|
if Rails.env.development? || Rails.env.test?
|
2010-09-03 11:26:20 +00:00
|
|
|
|
2010-09-23 06:01:40 +00:00
|
|
|
require "silent-postgres/railtie"
|
|
|
|
|
|
|
|
module SilentPostgres
|
2011-01-15 15:57:25 +00:00
|
|
|
SILENCED_METHODS = %w(tables table_exists? indexes column_definitions pk_and_sequence_for last_insert_id)
|
2010-09-23 06:01:40 +00:00
|
|
|
|
|
|
|
def self.included(base)
|
|
|
|
SILENCED_METHODS.each do |m|
|
|
|
|
base.send :alias_method_chain, m, :silencer
|
|
|
|
end
|
2010-09-03 11:26:20 +00:00
|
|
|
end
|
2010-09-23 06:01:40 +00:00
|
|
|
|
|
|
|
SILENCED_METHODS.each do |m|
|
2011-01-15 15:57:25 +00:00
|
|
|
m1, m2 = if m =~ /^(.*)\?$/
|
|
|
|
[$1, '?']
|
|
|
|
else
|
|
|
|
[m, nil]
|
|
|
|
end
|
|
|
|
|
2010-09-23 06:01:40 +00:00
|
|
|
eval <<-METHOD
|
2011-01-15 15:57:25 +00:00
|
|
|
def #{m1}_with_silencer#{m2}(*args)
|
2010-09-23 06:01:40 +00:00
|
|
|
@logger.silence do
|
2011-01-15 15:57:25 +00:00
|
|
|
#{m1}_without_silencer#{m2}(*args)
|
2010-09-23 06:01:40 +00:00
|
|
|
end
|
2010-09-03 11:26:20 +00:00
|
|
|
end
|
2010-09-23 06:01:40 +00:00
|
|
|
METHOD
|
|
|
|
end
|
2010-09-03 11:26:20 +00:00
|
|
|
end
|
2010-09-03 11:40:07 +00:00
|
|
|
|
|
|
|
end
|
2010-09-23 06:01:40 +00:00
|
|
|
|