Class: Hanami::Utils::IO

Inherits:
Object
  • Object
show all
Defined in:
gems/gems/hanami-utils-1.3.0/lib/hanami/utils/io.rb

Overview

IO utils

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.silence_warnings { ... } ⇒ void

This method returns an undefined value.

Decreases the level of verbosity, during the execution of the given block.

Revised version of ActiveSupport's Kernel.with_warnings implementation

Examples:

require 'hanami/utils/io'

class Test
  TEST_VALUE = 'initial'
end

Hanami::Utils::IO.silence_warnings do
  Test::TEST_VALUE = 'redefined'
end

Yields:

  • the block of code that generates warnings.

See Also:

Since:

  • 0.1.0

def self.silence_warnings
  old_verbose = $VERBOSE
  $VERBOSE    = nil
  yield
ensure
  $VERBOSE = old_verbose
end