Hi Ara,

Hmmm... interesting approach.  I'm not sure I quite need the indirection
you've illustrated, but it's interesting to see all the different ways
you can solve the problem in Ruby.  The passing the class declaration as
a block to the Class:new method will require me to do some more
reading.  I haven't looked into the reflection/class operations much
yet.  I want to make sure that I understand exactly what's happening
here.  Instinctively, I think I understand what's going on, but need to
double-check.  Some things are still Ruby-101 to me at this stage.

Also, I have a question further down...

On Fri, 2005-08-19 at 16:20, Ara.T.Howard wrote:
>      harp:~ > cat a.rb
>      module Factory
>        @classes = {
>          'a' => (
>              Class::new do
>                class << self
>                  def foo; 42; end
>                end
>                def bar; 42.0; end
>              end
>          ),
>          'b' => (
>              Class::new do
>                class << self
>                  def foo; 'FORTY-TWO'; end
>                end
>                def bar; 'forty-two'; end
>              end
>          ),
>        }
>        def self::new(*a, &b)
>          class_for(a.shift)::new(*a, &b)

I'm assuming you're doing the 'a.shift' call here to allow you to
specify all of the arguments you might need to the constructor.  Is that
correct?  Thus you could potentially write something like:

	ref = Factory::new 'a', 'param1', 'param2'

which would allow you to have the class 'a' support a constructor taking
the two parameters (and, of course, the optional block).

Anyway, thanks for the neat example! :)

ast

***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access to this email by anyone other than the intended addressee is unauthorized.  If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.  If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************