aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/misc.rb
diff options
context:
space:
mode:
authorJosh Susser <josh@hasmanythrough.com>2009-01-16 17:26:08 -0800
committerPratik Naik <pratiknaik@gmail.com>2009-01-18 00:47:38 +0000
commit78f2c19ae7f9236591c261eecdf0c4b570e3ea1e (patch)
tree399b9125a11c1a592518a310226d94750bfe0f38 /activesupport/lib/active_support/core_ext/object/misc.rb
parent3b1cd9e525fa74c681a1bd2261881d16d5d9106d (diff)
downloadrails-78f2c19ae7f9236591c261eecdf0c4b570e3ea1e.tar.gz
rails-78f2c19ae7f9236591c261eecdf0c4b570e3ea1e.tar.bz2
rails-78f2c19ae7f9236591c261eecdf0c4b570e3ea1e.zip
Refactor Object#try to use inheritance. [#1774 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/misc.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/misc.rb17
1 files changed, 0 insertions, 17 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/misc.rb b/activesupport/lib/active_support/core_ext/object/misc.rb
index c0a109ecf3..4acdfa3d6c 100644
--- a/activesupport/lib/active_support/core_ext/object/misc.rb
+++ b/activesupport/lib/active_support/core_ext/object/misc.rb
@@ -87,21 +87,4 @@ class Object
respond_to? "acts_like_#{duck}?"
end
- # 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.
- #
- # ==== Example :
- #
- # # Without try
- # @person ? @person.name : nil
- #
- # With try
- # @person.try(:name)
- #
- # # try also accepts arguments/blocks for the method it is trying
- # Person.try(:find, 1)
- # @people.try(:map) {|p| p.name}
- def try(method, *args, &block)
- send(method, *args, &block) unless self.nil?
- end
end