Since Ruby 2.4.0, there has been a deprecation warning for using certain features that have been deprecated. For example, Bignum
, Fixnum
, TRUE
, and FALSE
will all trigger deprecation warnings. While I'm fixing my code, there is a fair amount of code that I would like it silenced for, especially in Rails. How can I do this?
module Kernel
def suppress_warnings
original_verbosity = $VERBOSE
$VERBOSE = nil
result = yield
$VERBOSE = original_verbosity
return result
end
end
>> X = :foo
=> :foo
>> X = :bar
(irb):11: warning: already initialized constant X
=> :bar
>> suppress_warnings { X = :baz }
=> :baz
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With