From: Gavin Kistner Date: 2004-11-22T07:05:41+09:00 Subject: Inherited Data Background: As part of the home automation core I'm writing, I need a way to have introspection on methods which are exposed to the UI by various author-created 'plugins'. I've created the majority of the code for describing methods, but one problem is preventing me from continuing, and I'd appreciate your input: Summary: How would you store information about a class, which exposes that information in an inherited manner that matches the inheritance hierarchy of the class? Details: Consider the following simple case: require 'DescribeMethods.rb' class LightSwitch def turn_on #... end def turn_off #... end describe_method :turn_on, "Turn the switch on" describe_method :turn_off, "Turn the switch off" end class Dimmer < LightSwitch def set_level( n ) #... end describe_method :set_level, "Set the brightness level of the light", ... end I'd like to be able to know that a Dimmer instance has three methods which are described. How should I do it? a) Require the user to copy/paste descriptions from ancestor classes into the child? b) Copy the methods from an ancestor class into the storage for the subclass when it is inherited? (Failing to add new methods if they're later described in the parent and duplicating storage.) c) Store each method in a collection for that class, and every time I inspect the described methods for a class, iterate up the #superclass tree and look at ancestors? d) Store the description as a custom property in the method itself? e) ??? -- (-, /\ \/ / /\/