On Mar 25, 10:21=A0am, PsiPro <arjes... / gmail.com> wrote:
> So I am working on some metaprograming and have some questions about
> how to get what I need out of dynamic classes.
>
> Right now I know I can define dynamic classes like so:
> a) TestClass =3D Class.new
> b) var_class =3D Class.new
>
> These work as expected but I need the functionality provided by case
> A. Specifically I need to have the instances respond to .class
> appropriately. .class for case B returns Class, while case A responds
> TestClass
>
> The reason I need to do this is that I want to dynamically generate
> classes, including their names. How can I accomplish this?
>
> My desired results:
>
> variable =3D Class.new
> variable.class.name =3D=3D 'variable'
>
> OR, I need to be able to assign a dynamic constant name (I know I
> know).
>
> Any help would be appreciated.

So I figured it out on my own, but still need some feedback.

Running
x=3D"Foo"
c =3D eval("ClassNamePrefix#{x} =3D Class.new")

provided the desired results. I don't like the idea of using eval if
at all possible tho, any feedback would be greatly appreciated.

Thank you.