Module: Kernel

Defined in:
lib/ironnails/core_ext/kernel.rb

Instance Method Summary collapse

Instance Method Details

#silence_warningsObject

Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.

silence_warnings do
  value = noisy_call # no warning voiced
end

noisy_call # warning voiced


10
11
12
13
14
15
# File 'lib/ironnails/core_ext/kernel.rb', line 10

def silence_warnings
  old_verbose, $VERBOSE = $VERBOSE, nil
  yield
ensure
  $VERBOSE = old_verbose
end

#using(o = nil) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/ironnails/core_ext/kernel.rb', line 17

def using(o=nil)
  begin
    yield if block_given?
  ensure
    o.dispose 
  end
end