Hi--
Little bit of conundrum. I have a variables that tracks information
about methods. So it needs to work within the context of the class
hierarchy. At the same time I need to access that information from the
instance level. I worked it out with one exception --singleton, b/c I
do something like:
class Foo
def self.dolist( name )
list = nil
ancestors.each do |a|
if d = a.instance_variable_get("@dolist")
list = d[name.to_sym]
break if list
end
end
list
end
def foo
self.class.dolist()
end
end
This works unless there is singleton in the hierarchy that has @dolist
defined. But I don't want to call directly on the singleton in foo in
case the singleton doesn't exist --I think that would be an exceedingly
inefficient. Is there another way?
Thanks,
T.