On Mar 25, 3:44 pm, PsiPro <[email protected]> wrote:
> I'm looking to define dynamic classes, and in order to get them to
> play nicely with Rails I need them to behaving like a constantly
> defiend class.
>
> foo = Class.new
>
> Won't work AFAIK because
>
> foo.class == Class
Well that should always be true - classes should be instances of
class. You do end up with foo.name == nil which I have seen confusing
bits of rails
>
> If the new class is defined to a constant however it will work.
>
> Foo = Class.new
>
> So far the only way I know of to do this is to use eval.
>
> newclass = eval("Foo#{some_string} = Class.new")
>
> and then I can define new class as I see fit. However I do not want to
> use eval if I can help it. Can anyone make any suggestions?
Try const_set
Fred
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.