Trans
8/22/2006 1:45:00 PM
Funny! I didn't even realize that this is essentially the same as the
Once class I wrote just a week ago!
class Once
# Privatize a few Kernel methods that are most likely to clash,
# but arn't essential here.
private :class, :clone, :display, :type, :method, :to_a, :to_s
def initialize( target )
@self = target
@cache = {}
end
def self ; @self ; end
def method_missing( meth, *args, &blk )
return @cache[ [meth,*args] ] if @cache.key?( [meth, *args] )
@cache[ [meth,*args] ] = @self.send( meth, *args, &blk )
end
end
So I was looking at the differences with your implementation. What does
the un_cahce do for us?
Thanks,
T.
PS. I like the name Cache better and will use that, and will merge your
implmentation and mine together for Facets.