Joel VanderWerf wrote: > Damjan Rems wrote: >> end >> .... >> end >> run_class('my_src') >> >> Ruby is wonderful language which allows us to do this. But the >> substitution part is kinda ugly to me. >> >> So is there a better way of doing this? > > One idea: define A and B as modules instead of classes. Then, when you > load the file that defines "class MySrc < Abstract", you don't have to > substitute anything. Just include the module, as in: > > Module ModA; ...; end > > load filename + ".rb" > cl = Object.const_get( File.basename(filename).capitalize ) > cl.class_eval {include ModA} > > Now, instances of cl will have all the methods of module ModA. I am trying this variation for now. And it might look like good until here: > cl.class_eval {include ModA} I guess my version is wrong cl.class_eval { "include 'DrgReports#{opts[:format]}'" } report = eval( File.basename(custom_class).capitalize + '.new' ) because after this I get error that method found in included module is missing. How to write the line correct? by TheR -- Posted via http://www.ruby-forum.com/.