I am loading a class from a string like this
Kernel.const_get(some_class_name).new
which works, but what is the correct way to do this?
More importantly, is there any way to unload a class? I have tried
Object.send(:remove_const, some_class_name)
but that is not the same as before the class was ever loaded.
Note: related to this.
Since you tagged the question with Rails, then you can do
Example
remove_constworks, but you need to call it from the object space where the constant is defined. Also, remember to pass a symbol as the constant name.Example