A
abc
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!
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!