Method: Kernel#autoload
- Defined in:
- load.c
#autoload(const, filename) ⇒ nil
Registers filename to be loaded (using Kernel::require) the first time that const (which may be a String or a symbol) is accessed.
autoload(:MyModule, "/usr/local/lib/modules/my_module.rb")
If const is defined as autoload, the file name to be loaded is replaced with filename. If const is defined but not as autoload, does nothing.
1540 1541 1542 1543 1544 1545 1546 1547 1548 |
# File 'load.c', line 1540
static VALUE
rb_f_autoload(VALUE obj, VALUE sym, VALUE file)
{
VALUE klass = rb_class_real(rb_vm_cbase());
if (!klass) {
rb_raise(rb_eTypeError, "Can not set autoload on singleton class");
}
return rb_mod_autoload(klass, sym, file);
}
|