有没有办法在 2.4.0 中消除 Ruby 的弃用警告?

Is there a way to silence Ruby's deprecation warning in 2.4.0?

自 Ruby 2.4.0 以来,使用某些已弃用的功能时会出现弃用警告。例如,BignumFixnumTRUEFALSE 都会触发弃用警告。当我修复我的代码时,有相当多的代码我希望它保持沉默,尤其是在 Rails 中。我该怎么做?

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