From 44e6aa7e19928f401e8728ddc2f4d7f6e3d6e105 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 17 Nov 2006 14:09:46 +0000 Subject: Improve readability. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5547 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/deprecation.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb index 8960a03e66..b9c732691a 100644 --- a/activesupport/lib/active_support/deprecation.rb +++ b/activesupport/lib/active_support/deprecation.rb @@ -37,10 +37,9 @@ module ActiveSupport @silenced end - # Silence deprecations for the duration of the provided block. For internal - # use only. + # Silence deprecation warnings within the block. def silence - old_silenced, @silenced = @silenced, true # We could have done behavior = nil... + old_silenced, @silenced = @silenced, true yield ensure @silenced = old_silenced @@ -153,13 +152,17 @@ module ActiveSupport end private - def warn(callstack, called, args) - ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) - end - def method_missing(called, *args, &block) warn caller, called, args - @instance.__send__(@method).__send__(called, *args, &block) + target.__send__(called, *args, &block) + end + + def target + @instance.__send__(@method) + end + + def warn(callstack, called, args) + ActiveSupport::Deprecation.warn("#{@var} is deprecated! Call #{@method}.#{called} instead of #{@var}.#{called}. Args: #{args.inspect}", callstack) end end end -- cgit v1.2.3