silent-postgres/lib/silent-postgres.rb
2010-11-05 05:28:52 +00:00

27 lines
559 B
Ruby
Executable File

if Rails.env.development? || Rails.env.test?
require "silent-postgres/railtie"
module SilentPostgres
SILENCED_METHODS = %w(tables indexes column_definitions pk_and_sequence_for last_insert_id)
def self.included(base)
SILENCED_METHODS.each do |m|
base.send :alias_method_chain, m, :silencer
end
end
SILENCED_METHODS.each do |m|
eval <<-METHOD
def #{m}_with_silencer(*args)
@logger.silence do
#{m}_without_silencer(*args)
end
end
METHOD
end
end
end