Method: Kernel#autoload
- Defined in:
- load.c
#autoload ⇒ 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")
1229 1230 1231 1232 1233 1234 1235 1236 1237 |
# File 'load.c', line 1229
static VALUE
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
{
VALUE klass = rb_class_real(rb_vm_cbase());
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "Can not set autoload on singleton class");
}
return rb_mod_autoload(klass, sym, file);
}
|