diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-09 14:27:35 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-09 14:27:35 +0000 |
commit | 35a51b2538d49f3cf69d3fa7d4eef371ef336aaf (patch) | |
tree | ca98541cdf729be866a9943cf5a5ea9d82f58621 | |
parent | 4cdeb0fb7f74565fc746c02f56a9be1a8d9f9efd (diff) |
* lib/delegate.rb (Delegator#method_missing)
(DelegateClass()#method_missing): Properly pass a given block
through. [ruby-dev:38390]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/delegate.rb | 12 |
2 files changed, 12 insertions, 6 deletions
@@ -1,3 +1,9 @@ +Sat May 9 23:26:04 2009 Akinori MUSHA <[email protected]> + + * lib/delegate.rb (Delegator#method_missing) + (DelegateClass()#method_missing): Properly pass a given block + through. [ruby-dev:38390] + Fri May 8 02:34:25 2009 Akinori MUSHA <[email protected]> * lib/set.rb (SortedSet#add): Do not require each newly added diff --git a/lib/delegate.rb b/lib/delegate.rb index bd2b5e4813..43549946c9 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -151,12 +151,12 @@ class Delegator alias initialize_methods initialize # Handles the magic of delegation through \_\_getobj\_\_. - def method_missing(m, *args) + def method_missing(m, *args, &block) target = self.__getobj__ unless target.respond_to?(m) - super(m, *args) + super(m, *args, &block) end - target.__send__(m, *args) + target.__send__(m, *args, &block) end # @@ -264,11 +264,11 @@ def DelegateClass(superclass) def initialize(obj) # :nodoc: @_dc_obj = obj end - def method_missing(m, *args) # :nodoc: + def method_missing(m, *args, &block) # :nodoc: unless @_dc_obj.respond_to?(m) - super(m, *args) + super(m, *args, &block) end - @_dc_obj.__send__(m, *args) + @_dc_obj.__send__(m, *args, &block) end def respond_to?(m, include_private = false) # :nodoc: return true if super |