Sha256: f884f170b103d499361e337664256c68667d886b489946b99dc9eb7a07eeec9f
Contents?: true
Size: 960 Bytes
Versions: 20
Compression:
Stored size: 960 Bytes
Contents
# frozen_string_literal: true module Hanami module Utils # IO utils # # @since 0.1.0 class IO # Decreases the level of verbosity, during the execution of the given block. # # Revised version of ActiveSupport's `Kernel.with_warnings` implementation # @see https://github.com/rails/rails/blob/v4.1.2/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L25 # # @yield the block of code that generates warnings. # # @return [void] # # @since 0.1.0 # # @example # require 'hanami/utils/io' # # class Test # TEST_VALUE = 'initial' # end # # Hanami::Utils::IO.silence_warnings do # Test::TEST_VALUE = 'redefined' # end def self.silence_warnings old_verbose = $VERBOSE $VERBOSE = nil yield ensure $VERBOSE = old_verbose end end end end
Version data entries
20 entries across 20 versions & 1 rubygems