aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/try.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/try.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/try.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/try.rb b/activesupport/lib/active_support/core_ext/object/try.rb
index a1c63a0e54..48e9d04787 100644
--- a/activesupport/lib/active_support/core_ext/object/try.rb
+++ b/activesupport/lib/active_support/core_ext/object/try.rb
@@ -1,4 +1,7 @@
class Object
+ ##
+ # :method: try
+ #
# Invokes the method identified by the symbol +method+, passing it any arguments
# and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
#
@@ -19,13 +22,8 @@ class Object
# 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(method, *args, &block)
- send(method, *args, &block)
- end
- remove_method :try
+ # +try+ behaves like +Object#send+, unless called on +NilClass+.
+
alias_method :try, :__send__
end