From 5339f813be99012aba01586743d8b24f065e7034 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 13 Jan 2009 03:28:32 +0000 Subject: Change Object#try to raise NoMethodError on private methods and always return nil when Object is nil [Pratik Naik, Lawrence Pit] --- activesupport/lib/active_support/core_ext/object/misc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext/object/misc.rb') diff --git a/activesupport/lib/active_support/core_ext/object/misc.rb b/activesupport/lib/active_support/core_ext/object/misc.rb index 4570570bbc..c0a109ecf3 100644 --- a/activesupport/lib/active_support/core_ext/object/misc.rb +++ b/activesupport/lib/active_support/core_ext/object/misc.rb @@ -102,6 +102,6 @@ class Object # Person.try(:find, 1) # @people.try(:map) {|p| p.name} def try(method, *args, &block) - send(method, *args, &block) if respond_to?(method, true) + send(method, *args, &block) unless self.nil? end end -- cgit v1.2.3