diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-30 06:20:09 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-30 06:20:09 +0000 |
| commit | 7d7dbcb9660b88b581625844b619703c782e2b33 (patch) | |
| tree | d33ef363870dccb8536cbcc1ab3a8780df92ff7f /lib | |
| parent | a89a18d40744935921a9ccb093f7d061372af18d (diff) | |
| download | ruby-7d7dbcb9660b88b581625844b619703c782e2b33.tar.gz ruby-7d7dbcb9660b88b581625844b619703c782e2b33.tar.xz ruby-7d7dbcb9660b88b581625844b619703c782e2b33.zip | |
* eval.c (rb_eval): pre-evaluate argument for unambiguous
evaluation order. [ruby-dev:26383]
* lib/delegate.rb (Delegator::method_missing): forward unknown
method to the destination. suggested by
<christophe.poucet@gmail.com>. [ruby-talk:146776]
* process.c (detach_process_watcher): terminate process watcher
thread right after rb_waitpid() succeed. [ruby-talk:146430]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@8676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/delegate.rb | 8 | ||||
| -rw-r--r-- | lib/set.rb | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb index 9c89a8cc1..72b52f3d4 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -49,6 +49,14 @@ class Delegator end alias initialize_methods initialize + def method_missing(m, *args) + target = self.__getobj__ + unless target.respond_to?(m) + super(m, *args) + end + target.__send__(m, *args) + end + def __getobj__ raise NotImplementedError, "need to define `__getobj__'" end diff --git a/lib/set.rb b/lib/set.rb index 586a5d9f4..9e3dac06e 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -101,7 +101,6 @@ class Set if enum.class == self.class @hash.replace(enum.instance_eval { @hash }) else - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" clear enum.each { |o| add(o) } end @@ -254,7 +253,6 @@ class Set if enum.is_a?(Set) @hash.update(enum.instance_eval { @hash }) else - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" enum.each { |o| add(o) } end @@ -264,7 +262,6 @@ class Set # Deletes every element that appears in the given enumerable object # and returns self. def subtract(enum) - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" enum.each { |o| delete(o) } self end @@ -272,7 +269,6 @@ class Set # Returns a new set built by merging the set and the elements of the # given enumerable object. def |(enum) - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" dup.merge(enum) end alias + | ## @@ -281,7 +277,6 @@ class Set # Returns a new set built by duplicating the set, removing every # element that appears in the given enumerable object. def -(enum) - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" dup.subtract(enum) end alias difference - ## @@ -289,7 +284,6 @@ class Set # Returns a new array containing elements common to the set and the # given enumerable object. def &(enum) - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" n = self.class.new enum.each { |o| n.add(o) if include?(o) } n @@ -300,7 +294,6 @@ class Set # and the given enumerable object. (set ^ enum) is equivalent to # ((set | enum) - (set & enum)). def ^(enum) - enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" n = dup enum.each { |o| if n.include?(o) then n.delete(o) else n.add(o) end } n @@ -519,6 +512,7 @@ end module Enumerable # Makes a set from the enumerable object with given arguments. + # Needs to +require "set"+ to use this method. def to_set(klass = Set, *args, &block) klass.new(self, *args, &block) end @@ -573,7 +567,6 @@ end # end # # def replace(enum) -# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" # clear # enum.each { |o| add(o) } # @@ -581,7 +574,6 @@ end # end # # def merge(enum) -# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable" # enum.each { |o| add(o) } # # self |
