From: leon breedt Date: 2004-06-26T13:12:30+09:00 Subject: Re: "attr" like functions On Sat, 26 Jun 2004 09:22:57 +0900, Ben Giddings wrote: > 1) Is there a way to add the 'attr_with_desc' method without having to > modify the Module class? I'd like to keep it pristine, if possible. not sure why you're putting a class method in Module, putting it in the class itself would suffice? ---- class Describable def Describable.attr_with_desc(id, description) attr_accessor id @@desc ||= {} @@desc["@#{id.id2name}"] = description.to_s end def pretty_print instance_variables.each { |var| if @@desc.has_key?(var) puts "#{@@desc[var]}: #{eval(var)}" else puts "Instance var #{var}: #{eval(var)}" end } end end class Test-- regards, leon