From: Daniel Vartanov on 2 Jul 2010 04:21 Hi! I want to replace "default definee" when I require ruby file. A short example: http://gist.github.com/461094 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. -- Posted via http://www.ruby-forum.com/.
From: Lee Jarvis on 2 Jul 2010 10:50 [Note: parts of this message were removed to make it a legal post.] On 2 July 2010 09:21, Daniel Vartanov <daniel.vartanov(a)gmail.com> wrote: > Hi! I want to replace "default definee" when I require ruby file. > > A short example: http://gist.github.com/461094 > > 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. > -- > 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
From: Daniel Vartanov on 3 Jul 2010 23:36 It works, thanks! > You can't do this with require. You probably want module_eval -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: FasterCSV - Merge CSV Next: [ANN][Security] Ruby 1.9.1-p429 is out |