public Method

Module.autoload(p1, p2)

mod.autoload(name, filename)    nil

Registers filename to be loaded (using Kernel::require) the first time that name (which may be a String or a symbol) is accessed in the namespace of mod.

module A
end
A.autoload(:B, "b")
A::B.doit            # autoloads "b"

Source Code

/*
*  call-seq:
*     mod.autoload(name, filename)   => nil
*
*  Registers _filename_ to be loaded (using <code>Kernel::require</code>) 
*  the first time that _name_ (which may be a <code>String</code> or
*  a symbol) is accessed in the namespace of _mod_.
*
*     module A
*     end
*     A.autoload(:B, "b")
*     A::B.doit            # autoloads "b"
*/

static VALUE
rb_mod_autoload(mod, sym, file)
   VALUE mod;
   VALUE sym;
   VALUE file;
{
   ID id = rb_to_id(sym);

   Check_SafeStr(file);
   rb_autoload(mod, id, RSTRING(file)->ptr);
   return Qnil;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.