From: "Ara.T.Howard" Date: 2005-07-03T05:30:45+09:00 Subject: Re: Loading a file without cluttering the global namespace On Sat, 2 Jul 2005, Benjamin Hepp wrote: > Hello, > > I'm trying to build a module-mechanism in ruby so that I am able to load a > ruby-file without cluttering up the global namespace of the program. > > For example I want to be able to load a ruby-file, search for methods in > it, possibly execute one of them and then "unload" the file. When I call > Kernel#load with wrap = true, everything of the new file is put into an > anonymous Module, but every other file loaded in the new file itself is > put into the global namespace again. > > My questions: > > Is it at all possible to prevent this? If so, how to do it? > Can I access the anonymous Module in an easy manner? > How to delete/undefine a class or a method? > > Thanks in advance > Benjamin Hepp i use a similar pattern for loading 'subscriptions' in our near-realtime system. a subscription is a dynamically loaded class for which and instance is created and then it's run method is called. to support doing this without killing the global namespace i write this http://raa.ruby-lang.org/project/dynaload/ it should be just what you are looking for. cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================