K
Kevin McConnell
What's a good way to get at a Class instance, from a string containing
its name?
For example, say I have a string "Customer", and want to call
Customer.my_class_method(). I realise I could do something like:
# class_name = "Customer"
result = eval("#{class_name}.my_class_method()")
....but it smells like a hack to me, and so I suspect there's a more
"proper" way to get at the object I need...
Any pointers would be much appreciated!
Cheers,
Kevin
its name?
For example, say I have a string "Customer", and want to call
Customer.my_class_method(). I realise I could do something like:
# class_name = "Customer"
result = eval("#{class_name}.my_class_method()")
....but it smells like a hack to me, and so I suspect there's a more
"proper" way to get at the object I need...
Any pointers would be much appreciated!
Cheers,
Kevin