On May 16, 2006, at 8:21 PM, Wes Gamble wrote:

> Hey, I just thought of something.
>
> Is there a way to unload ("un-require") a module at runtime?  Is  
> there a
> way to load ("re-require") a module at runtime?
>
> Thanks,
> Wes
>

I think you may be over-estimating the relationship between modules  
and files.
One does not require modules, one requires files. One file may have  
many modules in it, or none. Regardless one can still 'require' that  
file.

One way to hack something so it gets stuck in a module is:

module Protect
   eval(File.read("path/to/file.rb"))
end

Then you access all the classes defined in file.rb like:

Protect::Node.new # etc.


> Wes Gamble wrote:
>> All,
>>
>> I have a namespace collision problem between a Rubygem (htmltools  
>> 1.09)
>> and a Rails framework class (in ActionPack 1.12.1).
>>
>> In order to use both, I will need to modify the namespace of one of
>> them.
>>
>> However, I would really like to not have to modify the existing  
>> gems and
>> I was thinking that maybe there might be some clever way to use the
>> Module class to "wrap" the offending module redefine it's namespace.
>>
>> Has anyone ever done anything like this?
>>
>> Otherwise, I will be looking at "taking ownership" of the gem code  
>> and
>> moving it to a locally - controlled location essentially freezing the
>> version of that Gem for my application
>>
>> Thanks,
>> Wes
>
>
> -- 
> Posted via http://www.ruby-forum.com/.
>