From: Christoph Date: 2005-04-25T12:38:09+09:00 Subject: Re: Strange behavior with SimpleDelegator and its Idioclass --------------010209030801050101090704 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Trans schrieb: >Perhaps I should point out that the strange thing about this is that >when the #bracket method in SD is NOT defined, then the module included >in the idioclass (singleton) is not called as one would expect it to >be. But when you add #bracket into SD, it "suddenly" works as it >should, and subsequently by passes the #bracket method just defined! > > > For the record I included a small modification of delegate.rb which matches your expectation. --------------010209030801050101090704 Content-Type: text/plain; name="delegate.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="delegate.rb" # Delegation class that delegates even methods defined in super class, # which can not be covered with normal method_missing hack. # # Delegator is the abstract delegation class. Need to redefine # `__getobj__' method in the subclass. SimpleDelegator is the # concrete subclass for simple delegation. # # Usage: # foo = Object.new # foo2 = SimpleDelegator.new(foo) # foo.hash == foo2.hash # => false # # Foo = DelegateClass(Array) # # class ExtArray true foo2.error # raise error! end --------------010209030801050101090704--