Silence for table_exists? method
This commit is contained in:
parent
0b79ce2284
commit
02fe343d56
@ -3,7 +3,7 @@ if Rails.env.development? || Rails.env.test?
|
|||||||
require "silent-postgres/railtie"
|
require "silent-postgres/railtie"
|
||||||
|
|
||||||
module SilentPostgres
|
module SilentPostgres
|
||||||
SILENCED_METHODS = %w(tables indexes column_definitions pk_and_sequence_for last_insert_id)
|
SILENCED_METHODS = %w(tables table_exists? indexes column_definitions pk_and_sequence_for last_insert_id)
|
||||||
|
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
SILENCED_METHODS.each do |m|
|
SILENCED_METHODS.each do |m|
|
||||||
@ -12,10 +12,16 @@ if Rails.env.development? || Rails.env.test?
|
|||||||
end
|
end
|
||||||
|
|
||||||
SILENCED_METHODS.each do |m|
|
SILENCED_METHODS.each do |m|
|
||||||
|
m1, m2 = if m =~ /^(.*)\?$/
|
||||||
|
[$1, '?']
|
||||||
|
else
|
||||||
|
[m, nil]
|
||||||
|
end
|
||||||
|
|
||||||
eval <<-METHOD
|
eval <<-METHOD
|
||||||
def #{m}_with_silencer(*args)
|
def #{m1}_with_silencer#{m2}(*args)
|
||||||
@logger.silence do
|
@logger.silence do
|
||||||
#{m}_without_silencer(*args)
|
#{m1}_without_silencer#{m2}(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
METHOD
|
METHOD
|
||||||
|
Loading…
Reference in New Issue
Block a user