summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-07 08:34:10 +0000
commitba06b1a81f81e089849c7c877eba7b1d3618b126 (patch)
tree57e77c2ade50f201b4aafdc071cf86fb95eb7016 /lib
parentf8fc9136223c83c2791566d3efa52843f89aa127 (diff)
dynamic (nested) local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/delegate.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 30b1a32c12..205d5e1fbd 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -8,12 +8,12 @@
# Usage:
# foo = Object.new
# foo = SimpleDelegator.new(foo)
-# foo.type # => Object
+# foo.hash == foo2.hash # => true
class Delegator
def initialize(obj)
- preserved = ["id", "equal?", "__getobj__"]
+ preserved = ["type", "id", "equal?", "__getobj__"]
for t in self.type.ancestors
preserved |= t.instance_methods
break if t == Delegator
@@ -52,6 +52,6 @@ SimpleDelegater = SimpleDelegator
if __FILE__ == $0
foo = Object.new
- foo = SimpleDelegator.new(foo)
- p foo.type # => Object
+ foo2 = SimpleDelegator.new(foo)
+ p foo.hash == foo2.hash # => true
end