Skip to content

Commit

Permalink
We have a very strict NO code changes policy.
Browse files Browse the repository at this point in the history
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 9290881.
  • Loading branch information
lifo committed Jan 26, 2009
1 parent 9290881 commit c9b8a26
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions activesupport/lib/active_support/core_ext/try.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,6 @@
class Object class Object
# Invokes the method identified by +symbol+, passing it any arguments # Tries to send the method only if object responds to it. Return +nil+ otherwise.
# and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does. # It will also forward any arguments and/or block like Object#send 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.
# #
# ==== Examples # ==== Examples
# #
Expand All @@ -15,15 +12,13 @@ class Object
# With try # With try
# @person.try(:name) # @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) # Person.try(:find, 1)
# @people.try(:collect) {|p| p.name} # @people.try(:collect) {|p| p.name}
#-- #--
# This method definition below is for rdoc purposes only. The alias_method call # This method def is for rdoc only. The alias_method below overrides it as an optimization.
# below overrides it as an optimization since +try+ behaves like +Object#send+, def try(method, *args, &block)
# unless called on +NilClass+. send(method, *args, &block)
def try(symbol, *args, &block)
send(symbol, *args, &block)
end end
alias_method :try, :__send__ alias_method :try, :__send__
end end
Expand Down

0 comments on commit c9b8a26

Please sign in to comment.