diff options
author | azul <azul@riseup.net> | 2016-06-15 14:22:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-15 14:22:08 +0200 |
commit | 3c6dc3d7b902b46b82a3d8cd38bd3fa896024beb (patch) | |
tree | 559b3998465248138b6f24a76b6b3e55e60f3986 /lib/kernel_ext.rb | |
parent | 5cad637a4a2a3de6b95ff1204fc29174e18b3124 (diff) | |
parent | 93258bd6fe6247e7af67f423243eba9808e920ee (diff) |
Merge pull request #3 from azul/refactor/transport-adapters
Refactor em specifics into http adapter
Diffstat (limited to 'lib/kernel_ext.rb')
-rw-r--r-- | lib/kernel_ext.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/kernel_ext.rb b/lib/kernel_ext.rb new file mode 100644 index 0000000..b5b58e0 --- /dev/null +++ b/lib/kernel_ext.rb @@ -0,0 +1,28 @@ +module Kernel + # 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 + def silence_warnings + with_warnings(nil) { yield } + end + + # Sets $VERBOSE to +true+ for the duration of the block and back to its + # original value afterwards. + def enable_warnings + with_warnings(true) { yield } + end + + # Sets $VERBOSE for the duration of the block and back to its original + # value afterwards. + def with_warnings(flag) + old_verbose, $VERBOSE = $VERBOSE, flag + yield + ensure + $VERBOSE = old_verbose + end +end |