summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-30 06:20:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-06-30 06:20:09 +0000
commit639bd5e78fa7d83b44c892afccb99869a886e533 (patch)
treed33ef363870dccb8536cbcc1ab3a8780df92ff7f /lib
parent00433666fd12d7e08c4c7c51593fc30265dd4508 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@8676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb8
-rw-r--r--lib/set.rb10
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 9c89a8cc1a..72b52f3d45 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 586a5d9f4d..9e3dac06ed 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