Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v4.2.9) is shown here.
silence_stream(stream)
public
Deprecated : this method is not thread safe Silences any stream for the
duration of the block.
silence_stream(STDOUT) do
puts 'This will never be seen'
end
puts 'But this will'
This method is not thread-safe.
# File activesupport/lib/active_support/core_ext/kernel/reporting.rb, line 51
def silence_stream(stream)
old_stream = stream.dup
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
stream.sync = true
yield
ensure
stream.reopen(old_stream)
old_stream.close
end