Is_class from a String?

I have a dynamic String entry and I want know if it represents some
any existing Class name (in a given modules set loaded)?

How to do that.
PS.: I’m using Rails and I need to know if there is some Model with a
given name (or symbol).

On 2/8/07, leandro nascimento camargo [email protected] wrote:

I have a dynamic String entry and I want know if it represents some
any existing Class name (in a given modules set loaded)?

How to do that.
PS.: I’m using Rails and I need to know if there is some Model with a
given name (or symbol).

Hi Leandro:

class Model
end
=> nil
Module.const_get(“Model”).is_a? Class
=> true

Hi Chris…
But If Model doesn’t exist I will get an error. =/
You see know the problem?
But maybe I can use const_defined before. =]
I will test here.
Thank you, anyway.

Yay!
Solved!
I simply used an exception treatment like this:

is_model =
begin
ActiveRecord.const_get(c.name[0…-3].camelize).is_a? Class
rescue StandardError => e
false
end