module Kernel
def class_eval(*args, &block)
def class_eval(*args, &block) singleton_class.class_eval(*args, &block) end
def concern(topic, &module_definition)
A shortcut to define a toplevel concern, not within a module.
def concern(topic, &module_definition) Object.concern topic, &module_definition end
def enable_warnings(&block)
Sets $VERBOSE to +true+ for the duration of the block and back to its
def enable_warnings(&block) with_warnings(true, &block) end
def silence_warnings(&block)
end
value = noisy_call # no warning voiced
silence_warnings do
value afterwards.
Sets $VERBOSE to +nil+ for the duration of the block and back to its original
def silence_warnings(&block) with_warnings(nil, &block) end
def suppress(*exception_classes)
end
puts 'This code is NOT reached'
1/0
suppress(ZeroDivisionError) do
Blocks and ignores any exception passed as argument if raised within the block.
def suppress(*exception_classes) yield rescue *exception_classes end
def with_warnings(flag)
Sets $VERBOSE for the duration of the block and back to its original
def with_warnings(flag) old_verbose, $VERBOSE = $VERBOSE, flag yield ensure $VERBOSE = old_verbose end