diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-01-26 00:40:37 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-01-26 00:40:37 +0000 |
commit | c9b8a26ba1cd8277580fc2a554fe3a67a52f1756 (patch) | |
tree | 5a6c79996f5c9dc242534b157ca76b75a6b0a2b0 /activesupport/lib/active_support | |
parent | 929088189de1d189c643246a491ba8fb5347b1d3 (diff) | |
download | rails-c9b8a26ba1cd8277580fc2a554fe3a67a52f1756.tar.gz rails-c9b8a26ba1cd8277580fc2a554fe3a67a52f1756.tar.bz2 rails-c9b8a26ba1cd8277580fc2a554fe3a67a52f1756.zip |
We have a very strict NO code changes policy.
Revert "An updated description of Object#try to better reflect changes documented at http://is.gd/hdmo and http://is.gd/hdmQ"
This reverts commit 929088189de1d189c643246a491ba8fb5347b1d3.
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/try.rb | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/core_ext/try.rb b/activesupport/lib/active_support/core_ext/try.rb index c7c7778a77..0dccd40c55 100644 --- a/activesupport/lib/active_support/core_ext/try.rb +++ b/activesupport/lib/active_support/core_ext/try.rb @@ -1,9 +1,6 @@ class Object - # Invokes the method identified by +symbol+, passing it any arguments - # and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does. - # - # *Unlike* that method however, a +NoMethodError+ exception will *not* be raised - # and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass. + # Tries to send the method only if object responds to it. Return +nil+ otherwise. + # It will also forward any arguments and/or block like Object#send does. # # ==== Examples # @@ -15,15 +12,13 @@ class Object # With try # @person.try(:name) # - # +try+ also accepts arguments and/or a block, for the method it is trying + # Try also accepts arguments/blocks for the method it is trying # Person.try(:find, 1) # @people.try(:collect) {|p| p.name} #-- - # This method definition below is for rdoc purposes only. The alias_method call - # below overrides it as an optimization since +try+ behaves like +Object#send+, - # unless called on +NilClass+. - def try(symbol, *args, &block) - send(symbol, *args, &block) + # This method def is for rdoc only. The alias_method below overrides it as an optimization. + def try(method, *args, &block) + send(method, *args, &block) end alias_method :try, :__send__ end |