summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-03 23:15:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-03 23:15:55 +0000
commit10e8419da621fb4e6a9dd8346a6df8c707f962ba (patch)
tree035b25b7154f37e8e396e2502ec651877856284b /lib
parent7a4621eecff07d1d82c0f17442491198749223c3 (diff)
downloadbundler-10e8419da621fb4e6a9dd8346a6df8c707f962ba.tar.gz
* lib/delegate.rb (Delegator): now inherits BasicObject.
[ruby-dev:39154], [Bug #2679], [ruby-dev:40242] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index b1f79582f4..473fa0cb8f 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -114,11 +114,21 @@
# subclasses. Subclasses should redefine \_\_getobj\_\_. For a concrete
# implementation, see SimpleDelegator.
#
-class Delegator
- [:to_s,:inspect,:=~,:!~,:===,:<=>].each do |m|
- undef_method m
+class Delegator < BasicObject
+ # :stopdoc:
+ def class
+ (class << self; self; end).superclass
end
+ def extend(*mods)
+ (class << self; self; end).class_eval {include(*mods)}
+ end
+
+ def self.const_missing(n)
+ ::Object.const_get(n)
+ end
+ # :startdoc:
+
#
# Pass in the _obj_ to delegate method calls to. All methods supported by
# _obj_ will be delegated to.
@@ -131,12 +141,12 @@ class Delegator
def method_missing(m, *args, &block)
begin
target = self.__getobj__
- unless target.respond_to?(m)
+ unless target.respond_to?(m, true)
super(m, *args, &block)
else
target.__send__(m, *args, &block)
end
- rescue Exception
+ rescue ::Exception
if i = $@.index{|s| %r"\A#{Regexp.quote(__FILE__)}:\d+:in `method_missing'\z"o =~ s}
$@[0..i] = []
end
@@ -248,17 +258,6 @@ class SimpleDelegator<Delegator
raise ArgumentError, "cannot delegate to self" if self.equal?(obj)
@delegate_sd_obj = obj
end
-
- def initialize(obj) # :nodoc:
- (self.public_methods - Delegator.public_api).each do |m|
- class << self
- self
- end.class_eval do
- undef_method m
- end
- end
- super
- end
end
# :stopdoc: