Unloading (or unrequiring) a file

Hey all,

I'm trying to dynamically load parts of code to make things and methods available.

The catch is that I'd also like to make those things and methods UNavailable as well (or load something else in place of the original loaded item).

I know there's no Kernel#unload, so how can I achieve my goal?

Thanks,
aRi
-------------------------------------------|
Nietzsche is my copilot

Hey all,

I'm trying to dynamically load parts of code to make things and
methods available.

The catch is that I'd also like to make those things and methods
UNavailable as well (or load something else in place of the original
loaded item).

I know there's no Kernel#unload, so how can I achieve my goal?

As far as methods go there's remove_method and undef_method. For
constants theres remove_const. An idea I've had was to fork, although
that's a little heavy handed

eg:

... code ...
pid = fork do
   require 'this_will_go_away'
   but_so_will_this_var = ThisWillGoAway.new
   but_so_will_this_var.do_something
end

Process.wait pid

p but_so_will_this_var # NameError

ยทยทยท

On 8/17/07, Ari Brown <ari@aribrown.com> wrote:

Thanks,
aRi
-------------------------------------------|
Nietzsche is my copilot