Sha256: d7ae8173a822f0a1ebf3e187291b6e75f0d0d88774cefe9b814264a163e6d5da

Contents?: true

Size: 929 Bytes

Versions: 33

Compression:

Stored size: 929 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

33 entries across 33 versions & 1 rubygems

Version Path
hanami-utils-1.3.6 lib/hanami/utils/io.rb
hanami-utils-1.3.5 lib/hanami/utils/io.rb
hanami-utils-1.3.4 lib/hanami/utils/io.rb
hanami-utils-1.3.3 lib/hanami/utils/io.rb
hanami-utils-1.3.2 lib/hanami/utils/io.rb
hanami-utils-1.3.1 lib/hanami/utils/io.rb
hanami-utils-1.3.0 lib/hanami/utils/io.rb
hanami-utils-1.3.0.beta1 lib/hanami/utils/io.rb
hanami-utils-1.2.0 lib/hanami/utils/io.rb
hanami-utils-1.2.0.rc2 lib/hanami/utils/io.rb
hanami-utils-1.2.0.rc1 lib/hanami/utils/io.rb
hanami-utils-1.2.0.beta2 lib/hanami/utils/io.rb
hanami-utils-1.2.0.beta1 lib/hanami/utils/io.rb
hanami-utils-1.1.2 lib/hanami/utils/io.rb
hanami-utils-1.1.1 lib/hanami/utils/io.rb
hanami-utils-1.1.0 lib/hanami/utils/io.rb
hanami-utils-1.1.0.rc1 lib/hanami/utils/io.rb
hanami-utils-1.1.0.beta3 lib/hanami/utils/io.rb
hanami-utils-1.1.0.beta2 lib/hanami/utils/io.rb
hanami-utils-1.0.4 lib/hanami/utils/io.rb