aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-24 17:03:27 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-24 17:03:27 -0700
commit1e72610e76dd678621a0606b698673bd44650f68 (patch)
tree292037d6c0cee3d4d6639f61610c52d5f56689a4
parentfe7d3dbb023f7eb08cfa1860ed29ab2cddc92ddb (diff)
downloadrails-1e72610e76dd678621a0606b698673bd44650f68.tar.gz
rails-1e72610e76dd678621a0606b698673bd44650f68.tar.bz2
rails-1e72610e76dd678621a0606b698673bd44650f68.zip
Condense to Kernel#with_warnings
-rw-r--r--activesupport/lib/active_support/core_ext/kernel/reporting.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb
index 0f101e8fa4..d9b84e6543 100644
--- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb
+++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb
@@ -7,15 +7,17 @@ module Kernel
#
# noisy_call # warning voiced
def silence_warnings
- old_verbose, $VERBOSE = $VERBOSE, nil
- yield
- ensure
- $VERBOSE = old_verbose
+ 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
- old_verbose, $VERBOSE = $VERBOSE, true
+ 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
@@ -56,4 +58,4 @@ module Kernel
raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
end
end
-end \ No newline at end of file
+end