Undefining a method in Ruby is pretty simple, I can just use undef METHOD_NAME.
Is there anything similar for a class? I am on MRI 1.9.2.
I have to undefine an ActiveRecord Model, run two lines of code, and restore the model back to its original form.
The problem is, I have an model Contact and I am using a company’s API and it happens that they have some class called Contact, and changing my model name would be lot of work for me.
What can I do in this situation?
EDIT Just noticed your edit, removing the constant is probably not the best way to achieve what you’re looking for. Why not just move one of the
Contactclasses into a separate namespace.EDIT2 You could also rename your class temporarily like this:
Again, the trouble with this is that you’ll still have the newer
Contactclass so you’ll have to remove that again. I would really recommend name-spacing your classes instead. This will also help you avoid any loading issues