summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-19 16:27:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-19 16:27:40 +0000
commita9a6c103e536bf63c24fc2c207ee63072c73a450 (patch)
treeb93818467ffe44b2860059ba60cbf93d8fc4d2ad /lib
parentb9294f226b87808c1c1b2b33d3fc27a11a1a7a21 (diff)
delegate.rb: refix r43682
* lib/delegate.rb (Delegator#send): separate from method_missing so that super calls proper method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 74b13aa8a3..b929895d1f 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -74,7 +74,18 @@ class Delegator < BasicObject
$@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
end
end
- alias send method_missing
+
+ #
+ # Handles the magic of delegation through \_\_getobj\_\_.
+ #
+ def send(m, *args, &block)
+ target = self.__getobj__
+ begin
+ target.respond_to?(m) ? target.__send__(m, *args, &block) : super(m, *args, &block)
+ ensure
+ $@.delete_if {|t| %r"\A#{Regexp.quote(__FILE__)}:#{__LINE__-2}:"o =~ t} if $@
+ end
+ end
#
# Checks for a method provided by this the delegate object by forwarding the