Method: Module#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 in the namespace of mod.
module A
end
A.autoload(:B, "b")
A::B.doit # autoloads "b"
If const in mod is defined as autoload, the file name to be loaded is replaced with filename. If const is defined but not as autoload, does nothing.
1476 1477 1478 1479 1480 1481 1482 1483 1484 |
# File 'load.c', line 1476 static VALUE rb_mod_autoload(VALUE mod, VALUE sym, VALUE file) { ID id = rb_to_id(sym); FilePathValue(file); rb_autoload_str(mod, id, file); return Qnil; } |