aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/deprecation.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-06-04 11:05:46 +1200
committerMichael Koziarski <michael@koziarski.com>2008-06-04 11:05:46 +1200
commite3c26e9926948587efcc8d31c729395093407df6 (patch)
tree358f418791a56620c32a48776739b4fdf39d3cb0 /activesupport/lib/active_support/deprecation.rb
parentb9a9b91a3e3b892ab72ff5c618181747d6b4be04 (diff)
parent8afa725f4b98a6e0ceee4792e8ebaebb6189e5f6 (diff)
downloadrails-e3c26e9926948587efcc8d31c729395093407df6.tar.gz
rails-e3c26e9926948587efcc8d31c729395093407df6.tar.bz2
rails-e3c26e9926948587efcc8d31c729395093407df6.zip
Merge branch 'master' into patches
Diffstat (limited to 'activesupport/lib/active_support/deprecation.rb')
-rw-r--r--activesupport/lib/active_support/deprecation.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/deprecation.rb b/activesupport/lib/active_support/deprecation.rb
index 758aef5445..ebdaf86146 100644
--- a/activesupport/lib/active_support/deprecation.rb
+++ b/activesupport/lib/active_support/deprecation.rb
@@ -144,17 +144,11 @@ module ActiveSupport
end
end
- # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
- # which emits deprecation warnings on any method call (except +inspect+).
- class DeprecatedInstanceVariableProxy #:nodoc:
+ class DeprecationProxy #:nodoc:
silence_warnings do
instance_methods.each { |m| undef_method m unless m =~ /^__/ }
end
- def initialize(instance, method, var = "@#{method}")
- @instance, @method, @var = instance, method, var
- end
-
# Don't give a deprecation warning on inspect since test/unit and error
# logs rely on it for diagnostics.
def inspect
@@ -166,7 +160,16 @@ module ActiveSupport
warn caller, called, args
target.__send__(called, *args, &block)
end
+ end
+ # Stand-in for <tt>@request</tt>, <tt>@attributes</tt>, <tt>@params</tt>, etc.
+ # which emits deprecation warnings on any method call (except +inspect+).
+ class DeprecatedInstanceVariableProxy < DeprecationProxy #:nodoc:
+ def initialize(instance, method, var = "@#{method}")
+ @instance, @method, @var = instance, method, var
+ end
+
+ private
def target
@instance.__send__(@method)
end
@@ -176,6 +179,21 @@ module ActiveSupport
end
end
+ class DeprecatedConstantProxy < DeprecationProxy #:nodoc:
+ def initialize(old_const, new_const)
+ @old_const = old_const
+ @new_const = new_const
+ end
+
+ private
+ def target
+ @new_const.to_s.constantize
+ end
+
+ def warn(callstack, called, args)
+ ActiveSupport::Deprecation.warn("#{@old_const} is deprecated! Use #{@new_const} instead.", callstack)
+ end
+ end
end
end