From: Patrick Narkinsky Date: 2003-01-26T12:34:41+09:00 Subject: Reflection for instance variables? Hi. I'm brand new to Ruby, so please pardon if this question is naive, but I have not been able to figure it out. I would like to come up with a way to define a method in a superclass that would give me a list of variables in a subclass. So: class Father @h_test = "1234" @h_test2 = "12345" def Father.vars return self.instance_vars # This does not work. end end class Son < Father @h_test3 = "123456" end print Son::vars ## end listing Would give me ['h_test', 'h_test2', 'h_test3']. It seems to me that the key would be to get a reference to the Class object for the subclass, but can't seem to figure out how to do that. Suggestions? (For the curious, I'm trying to do something in Ruby I saw in objective-c. This class allowed you to define a subclass, define the variables in the subclass, then it would create the sql, etc. automagically.) Thanks, Patrick