It seems that a DelegateClass does not properly delegate to a WeakRef:
require 'delegate'
require 'weakref'
class Foo
def method_missing(*args)
p args
end
end
f = Foo.new
f.foo
w = WeakRef.new(f)
w.foo
class Bar < DelegateClass(WeakRef)
def initialize
@obj = Foo.new
super(WeakRef.new(@obj))
end
end
b = Bar.new
b.foo
This produces:
[:foo]
[:foo]
mm.rb:24: undefined method `foo' for #<Bar:0x4027f300> (NameError)
Anyone know why this is happening? Any ideas on a workaround (I know I
can use a SimpleDelegate, but that has costs)?
Paul