From 29a5aeaae976bf8432d57ec996c7c81932a39de6 Mon Sep 17 00:00:00 2001 From: dmathieu <42@dmathieu.com> Date: Sat, 21 May 2011 23:43:12 +0200 Subject: don't raise NoMethodError the tried method doesn't exists --- activesupport/lib/active_support/core_ext/object/try.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/object') 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 -- cgit v1.2.3