Skip to content

Commit

Permalink
Merge [5763] from trunk.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5764 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 20, 2006
1 parent 4dcdf08 commit 8ec9f4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion activesupport/lib/active_support/deprecation.rb
Expand Up @@ -143,14 +143,21 @@ def collect_deprecations
end
end

# Stand-in for @request, @attributes, etc.
# Stand-in for @request, @attributes, @params, etc which emits deprecation
# warnings on any method call (except #inspect).
class DeprecatedInstanceVariableProxy
instance_methods.each { |m| undef_method m unless m =~ /^__/ }

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
target.inspect
end

private
def method_missing(called, *args, &block)
warn caller, called, args
Expand Down
4 changes: 4 additions & 0 deletions activesupport/test/deprecation_test.rb
Expand Up @@ -79,6 +79,10 @@ def test_deprecated_instance_variable_proxy
assert_deprecated('@request.to_s') { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
end

def test_deprecated_instance_variable_proxy_shouldnt_warn_on_inspect
assert_not_deprecated { assert_equal @dtc.request.inspect, @dtc.old_request.inspect }
end

def test_assert_deprecation_without_match
assert_deprecated do
@dtc.partially
Expand Down

0 comments on commit 8ec9f4d

Please sign in to comment.