aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authordmathieu <42@dmathieu.com>2011-05-21 23:43:12 +0200
committerdmathieu <42@dmathieu.com>2011-05-21 23:43:12 +0200
commit29a5aeaae976bf8432d57ec996c7c81932a39de6 (patch)
tree9ff3bdf6020c5c9a65791fb6f60c613c170e3567 /activesupport/lib/active_support/core_ext
parentf674aed150e4c87cd9f149307313114a597dfa8b (diff)
downloadrails-29a5aeaae976bf8432d57ec996c7c81932a39de6.tar.gz
rails-29a5aeaae976bf8432d57ec996c7c81932a39de6.tar.bz2
rails-29a5aeaae976bf8432d57ec996c7c81932a39de6.zip
don't raise NoMethodError the tried method doesn't exists
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/object/try.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb
index e77a9da0ec..4797c93e63 100644
--- a/activesupport/lib/active_support/core_ext/object/try.rb
+++ b/activesupport/lib/active_support/core_ext/object/try.rb
@@ -28,6 +28,8 @@ 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