From: Christoph (news_chr) Date: 2003-07-26T07:02:51+09:00 Subject: Re: Trouble with inherited "Steve Tuckner" wrote .... > In my case, I am interested in getting a string that would be specific to > that class (and not the class name). I am using this name as a hash key from > the name to the class. > > Now I can simply save the class in a list and then when the hash would be > used later, I can simply generate the hash at that time for each request. > This seems not as elegant but probably is not much of a real speed penalty. > > Is there a better more elegant way of doing this? Basically you have to delay things until the information in your subclass becomes available. For example you could define a thread in inherited which checks for this information at fixed time intervals or something like this --- class A def self.singleton_method_added(sym) super unless self.equal?(A) or sym != :my_name name = self.my_name puts "the inheriting classes name is '#{name}'" end end end class B < A class << self def my_name "the B class" end end end --- (This probably doesn't work with 1.6 ..) /Christoph