On Aug 1, 2006, at 5:04 PM, Brian Palmer wrote:

> You can use `Module.const_missing` to autoload a file the first  
> time the class in that file is mentioned in the code. So you could  
> write an `Object.const_missing(name)` method that translates the  
> constant into a file name of an expected format, then load that  
> file on-the-fly.

Ruby has a function for this though:

$ ri -T Kernel#autoload
-------------------------------------------------------- Kernel#autoload
      autoload(module, filename)   => nil
------------------------------------------------------------------------
      Registers filename to be loaded (using Kernel::require) the first
      time that module (which may be a String or a symbol) is accessed.

         autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")

James Edward Gray II