------art_40596_25670632.1157327766955
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I've got some downtime this weekend, so I'm pooring over various examples of
metaprogramming w/ Ruby.

I really like _why's example regarding Dwemthy, but am curious as to how to
achieve my end.

The article in question is here:

http://poignantguide.net/ruby/chapter-6.html#section3

_why's method allows us to build 'traits' for the character (by calling the
'trait' class method), and the meta programming behind the scenes builds an
'initialize' instance method for the class.

What if I want to build a second method called 'command'?  It should place
the argument in an array that can be referenced later.  It will need to also
build an initialize method for my class, but one of them will have to be
overwritten.

Does anyone have any smart ways to combine or chain these two initialize
methods together?

I ultimately want to do something like this:

class Dragon < Creature
   traits :life
   life 100

   command :fly

   def fly
     puts "I am flying..."
   end

end

After an instance is created, it will contain the instance variable
'commands', which is an array holding the symbol 'fly'.

Does anyone have any ideas?  In the end, I'd be adding more and more of
these commands to my DSL.  This is a DSL, right?  ;-)

------art_40596_25670632.1157327766955--