From: Brian Candler Date: 2007-03-02T06:21:47+09:00 Subject: Re: Newbie Question On Fri, Mar 02, 2007 at 06:12:40AM +0900, Brian Candler wrote: > def self.per_class > self.ancestors.each { |k| > k.instance_eval { return @per_class if defined? @per_class } > } > end P.S. I first wrote this as: def self.per_class self.ancestors.each { |k| return k.instance_variable_get(:@per_class) if k.instance_variables.include?("@per_class") } end I note that Object#instance_variables appears to return an array of strings, not an array of symbols as I would have expected. Also, I couldn't find anything like 'instance_variable_defined?', which is why I ended up having to search through the whole array of all instance variables. So the instance_eval form looked to be the better bet. Regards, Brian.