开发者

Unload a ruby class

I have the followin开发者_如何学编程g in the file a.rb:

require foo

and i need to unload foo, to load the foo from b.rb, c.rb and other files.

How i can do?


Object.send(:remove_const, :Foo)

assuming your class is named Foo.


I am not sure about the unloading part, but using load instead of require will always reload the file. However, when you use load you will need to include the .rb so in your case it would be load 'foo.rb' .

See http://www.fromjavatoruby.com/2008/10/require-vs-load.html

Kernel#load docs
Kernel#require docs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜