On Mon, Apr 14, 2008 at 2:32 PM, Gaudi Mi <gaudimila / yahoo.com> wrote:
> I have several classes in my application, e.g. Person, Employer, Office.
>  And obviously I have some Class methods for each, e.g. Person.find.
>
>  At one point in my application I will be referencing the Class name
>  dynamically, I will have it in a String.  So e.g. class = "Person".  I
>  want to send the Person class the 'find' message (call Person.find).
>  How do I do this in Ruby.  I've scoured the API and Google but it's a
>  hard thing to search for.
>
>  Thanks.
>  --
>  Posted via http://www.ruby-forum.com/.
>
>

Hmm others have told you how to do what you wanted. I however wonder
if the need of doing metaprogramming to
find your classes is really a good sign for your design.

If the following is feasible for you I might suggest something like
the following

MyClasses = { "Person" => Person, "Animal" => Animal ... }

or even

MyClasses={}
MyClasses["Person"] = Class::new {
   <your code here />
}
MyClasses["Animal"] = Class::new {
   <still your code here ;)/>
}

In other words do not store away something just to get it back again ;)

HTH
Robert

-- 
http://ruby-smalltalk.blogspot.com/

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein