From: Greg Brondo Date: 2004-04-01T02:29:21+09:00 Subject: script loading question I like working in the style of Java (one class per file) for some projects and I've emulated it for an email/webagent app. What I'm wondering is if there is a *better* or *builtin* way to do this. Here is my code: def loadAgents(path) Dir[path + "*Agent.rb"].each { |agent| agent = File.basename(agent) if agent =~ /^((\w+)Agent)\.rb/ require $1 $agentFactory[$2.downcase] = $1 end } end I initialize '$agentFactory' to '{}' and add 'lib/' to $: before calling loadAgents(). Then I can 'object = agentFactory[request].new()'. Also I can add agents just by writing the class in a new agent file in lib and restarting. I guess another question would be how can I reload 'lib/' without restarting? Does 'load' replace class definitions (it seems require is a 'one time thing')? Thanks! (I hope that made sense -- it does in my mind, but that's where I live -- not you ;-) Greg B.