Skip to content

Instantly share code, notes, and snippets.

@tiennou
Last active March 2, 2019 11:25
Show Gist options
  • Select an option

  • Save tiennou/1097ceda0edb5bd63671ae887481a31e to your computer and use it in GitHub Desktop.

Select an option

Save tiennou/1097ceda0edb5bd63671ae887481a31e to your computer and use it in GitHub Desktop.
Ruby Kernel#silence_warnings
module Kernel
def silence_warnings
with_warnings(nil) { yield }
end
def with_warnings(flag)
old_verbose, $VERBOSE = $VERBOSE, flag
yield
ensure
$VERBOSE = old_verbose
end
end unless Kernel.respond_to? :silence_warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment