Sunday, April 3, 2011

unloading dynamically declared class in ruby

I have a class defined using theClass.class_eval and Object.const_set(className, theClass). Is there any way to remove the definition of this class? During testing I need to load different versions of the same class.

From stackoverflow
  • Object.send(:remove_const, className) did the trick.

  • I see that doing Object.send(:remove_const, className) prevent to reload the same class..

    how to reload?

0 comments:

Post a Comment