Florian G. Pflug wrote:
> Hi
> 
> Is is possible to require() is file so, that all the classes and modules
> inside the file are put in a special module?
> 
> e.g
> 
> -----module.rb--------
> module Foo
> 	class Bar
> 	end
> end
> ----------------------
> 
> module NameSpace
> 	require 'foobar.rb'
> end
> 
> Now I would like class Bar to be accessable with 
> NameSpace::Foo::Bar, rather than with
> Foo::Bar
> 
> I tried require() and load(), but both seems to "switch" to the global
> namespace

load has a second parameter, which allows to execute the file in an anonymous module, 
but unless you have access to this anonymous module this doesn't help you in this situation.

Use eval!

module NameSpace
  eval File.readlines('foobar.rb').to_s
end


Regards,

  Michael

-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de