Last active
March 2, 2019 11:25
-
-
Save tiennou/1097ceda0edb5bd63671ae887481a31e to your computer and use it in GitHub Desktop.
Ruby Kernel#silence_warnings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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