From: nobu.nokada@... Date: 2003-01-26T23:51:03+09:00 Subject: Re: datafiles as Ruby source musings Hi, At Sun, 26 Jan 2003 21:57:18 +0900, nobu.nokada@softhome.net wrote: > > module Data > > load "datafile" > > end > > Kernel#load code in the file into toplevel context if (omitted) > second argument is false, or an anonymous module. > > If it were return that anonymous module, you can write as: Wrong. What you want is can be done as class Module def module_load(file) module_eval(IO.read(file)) end end class Class alias class_load module_load end Data = Module.new Data.module_load("datafile") > > where 'depend' and 'configure' are just methods in the current instance, and > > 'ALSA' a constant defined in a module that got included. But again using > > 'obj.instance_eval File.new("file").read' is the only thing I can think of. Is instance_eval really necessary? If you want to load into same module again, just module_load for that module too. -- Nobu Nakada