From: Robert Klemme Date: 2009-04-04T06:59:36+09:00 Subject: Re: Loading classes in order On 03.04.2009 23:32, Elias Orozco wrote: > Iñaki Baz Castillo wrote: >> El Viernes 03 Abril 2009, Elias Orozco escribió: >>> I haven't require yet. So can anyone help or give me any hint on how to >>> load them all dynamically and deal with those dependencies? >> path = File.dirname(__FILE__) + "/files_dir" >> >> require "#{path}/required_file1" >> require "#{path}/required_file2" >> require "#{path}/required_file3" >> >> Dir.chdir(path) >> Dir["*.rb"].each do |file| >> require "#{path}/#{file}" >> end > > Thanks Inaki, but in that example I will have to specify the require > files and that's exactly what I don't want. A lot of classes will be > copied into that folder and I can't hard-code all those requires. Personally I would prefer to make dependencies explicit and insert require statements in all of those files. That's the most reasonable solution and then the approach from above will work properly. An alternative might be to rescue any exceptions and require files again. Cheers robert