From 3cf7a0a46037f32b95b5ffb358cb898233d5c5db Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 Sep 2005 04:58:27 +0000 Subject: Added Kernel#silence_warnings and puts it into use throughout the framework git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2179 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support.rb | 1 - activesupport/lib/active_support/core_ext/kernel.rb | 14 ++++++++++++++ activesupport/lib/active_support/misc.rb | 8 -------- 3 files changed, 14 insertions(+), 9 deletions(-) delete mode 100644 activesupport/lib/active_support/misc.rb (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb index ba6945f3e5..7c7ae56e61 100644 --- a/activesupport/lib/active_support.rb +++ b/activesupport/lib/active_support.rb @@ -29,7 +29,6 @@ require 'active_support/inflector' require 'active_support/core_ext' require 'active_support/clean_logger' -require 'active_support/misc' require 'active_support/dependencies' require 'active_support/values/time_zone' \ No newline at end of file diff --git a/activesupport/lib/active_support/core_ext/kernel.rb b/activesupport/lib/active_support/core_ext/kernel.rb index a2cb827d77..d4c3114488 100644 --- a/activesupport/lib/active_support/core_ext/kernel.rb +++ b/activesupport/lib/active_support/core_ext/kernel.rb @@ -14,4 +14,18 @@ module Kernel yield value end + + # Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards. + # + # silence_warnings do + # noisy_call # no warning voiced + # end + # + # noisy_call # warning voiced + def silence_warnings + old_verbose, $VERBOSE = $VERBOSE, nil + yield + ensure + $VERBOSE = old_verbose + end end diff --git a/activesupport/lib/active_support/misc.rb b/activesupport/lib/active_support/misc.rb deleted file mode 100644 index 1ca00db1e7..0000000000 --- a/activesupport/lib/active_support/misc.rb +++ /dev/null @@ -1,8 +0,0 @@ -def silence_warnings - old_verbose, $VERBOSE = $VERBOSE, nil - begin - yield - ensure - $VERBOSE = old_verbose - end -end -- cgit v1.2.3