From: Ryan Pavlik Date: 2003-11-05T10:03:33+09:00 Subject: Re: Managing metadata about attribute types On Wed, 5 Nov 2003 09:38:16 +0900 Simon Kitching wrote: > Hi, > I was wondering if there were any other Ruby projects which have faced > this problem and come up with solutions? I would rather steal a solution > than invent one :-) Yep. I'll take this opportunity to shamelessly plug some modules. I do this in Mephle. First, I use the StrongTyping module and write new attr_ functions, so I can do this: attr_accessor_typed String, :foo, :bar Now #foo= and #bar= complain if they don't get a String. Even better, I can use StrongTyping's type querying on foo= and bar= to get what they take, if I need to. Next, I use the MetaTags module for actually tagging what attributes exist: class_info <<-DOC !Class: Foo !attr foo: Foo !attr bar: Bar: This is an optional description of bar. DOC class Foo : end Now I can ask for information about the Foo class and look through the attributes that way. It works... I generate UIs from this information... and I'm working on some tools to eliminate redundancy and required typing. hth, -- Ryan Pavlik "Mmm! Power lines and paint chips! My childhood rocks!" - 8BT