mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "don't raise NoMethodError the tried method doesn't exists"
This reverts commit 29a5aeaae9
.
This commit is contained in:
parent
2e9e647fee
commit
82d41c9698
2 changed files with 1 additions and 3 deletions
|
@ -28,8 +28,6 @@ class Object
|
|||
def try(*a, &b)
|
||||
if a.empty? && block_given?
|
||||
yield self
|
||||
elsif !a.empty? && !respond_to?(a.first)
|
||||
nil
|
||||
else
|
||||
__send__(*a, &b)
|
||||
end
|
||||
|
|
|
@ -99,7 +99,7 @@ class ObjectTryTest < Test::Unit::TestCase
|
|||
def test_nonexisting_method
|
||||
method = :undefined_method
|
||||
assert !@string.respond_to?(method)
|
||||
assert_nil @string.try(method)
|
||||
assert_raise(NoMethodError) { @string.try(method) }
|
||||
end
|
||||
|
||||
def test_nonexisting_method_with_arguments
|
||||
|
|
Loading…
Reference in a new issue