aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/deprecation.rb19
1 files changed, 11 insertions, 8 deletions
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