aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/misc.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-01-13 03:28:32 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-01-13 03:28:32 +0000
commit5339f813be99012aba01586743d8b24f065e7034 (patch)
treef0d575c3e55f0c22af6d36230a53ada30da6ba23 /activesupport/lib/active_support/core_ext/object/misc.rb
parent296ca4da1700eb27a7043112d22027444ea0e548 (diff)
downloadrails-5339f813be99012aba01586743d8b24f065e7034.tar.gz
rails-5339f813be99012aba01586743d8b24f065e7034.tar.bz2
rails-5339f813be99012aba01586743d8b24f065e7034.zip
Change Object#try to raise NoMethodError on private methods and always return nil when Object is nil [Pratik Naik, Lawrence Pit]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/misc.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/misc.rb2
1 files changed, 1 insertions, 1 deletions
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