Requiring files in a module context

Hi! I want to replace “default definee” when I require ruby file.

A short example: config1.rb · GitHub

Of course, it says that One::Configuration is an uninitialized constant.

So, here is my question: how to require configN.rb so that all
definitions are done inside the module?

Thanks in advance,
Daniel.

On 2 July 2010 09:21, Daniel V. [email protected] wrote:

Daniel.

Posted via http://www.ruby-forum.com/.

You can’t do this with require. You probably want module_eval

module One
module_eval File.read(“config1.rb”)
end

module Two
module_eval File.read(“config2.rb”)
end

def process(config)
puts config.value
end

process One::Configuration
process Two::Configuration

It works, thanks!

You can’t do this with require. You probably want module_eval