From: Michael Malone Date: 2009-03-02T05:57:37+09:00 Subject: Re: Delegating class methods class Klass extend Forwardable def_delegators :@object :method1, :method2, :method3 def initialize @object = SomeKlass.new end end > Hi all, > > how would you forward calls from class methods to a class atribute? > Like in: > > class Foo > @@hash = {} > > def self.size > @@hash.size > end > end > > I have to delegate a fairly large number of calls to an attribute. I'm > currently using method_missing, but I was wondering if there was a > cleaner way to do that as the method names are known at load time. I > didn't find any using the standard library. Perhaps using some > metaprogramming. > > Thanks! > > ======================================================================= This email, including any attachments, is only for the intended addressee. It is subject to copyright, is confidential and may be the subject of legal or other privilege, none of which is waived or lost by reason of this transmission. If the receiver is not the intended addressee, please accept our apologies, notify us by return, delete all copies and perform no other act on the email. Unfortunately, we cannot warrant that the email has not been altered or corrupted during transmission. =======================================================================