From: Robert Klemme on
On 02/04/2010 12:03 PM, Josh Cheek wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> Hi, not completely sure I understand what you are trying to do, but Robert's
> post got me interested, and I wanted to try it out.
> This is what I came up with: http://gist.github.com/294520
>
> ( mirrored at http://pastie.org/private/1gtz2apwaxac2rcgl3xsw because github
> is having issues http://twitter.com/github/status/8627608544 )
>
> Hopefully it's helpful, if not, maybe flesh out the example a bit more of
> what you want to do, and what you want other people to be able to do.

That's exactly what I had in mind. Thanks for fleshing it out!

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
From: Albert Schlef on
Josh Cheek wrote:
> Hi, not completely sure I understand what you are trying to do, but
> Robert's post got me interested, and I wanted to try it out.
> This is what I came up with: http://gist.github.com/294520
>
> module Command
> [...]
> def self.included( base )
> @registered_commands << base
> end

And when using a base class instead of a module, one could use the
Class#inherited hook (that's the route Ben Bleything, above, took in
'linen').

>
> cmd_class = class_name.classify.constantize

Better let each command tell us its name, or names. It allows for
several names (aliases) for a command.
--
Posted via http://www.ruby-forum.com/.