Sha256: b5035203de170cc52321f419bf84a6f18f85c70bd5e4d6dd4a058a095ba9c5f3

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

Contents

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

3 entries across 3 versions & 1 rubygems

Version Path
hanami-utils-0.7.2 lib/hanami/utils/io.rb
hanami-utils-0.7.1 lib/hanami/utils/io.rb
hanami-utils-0.7.0 lib/hanami/utils/io.rb