| Class | Adhearsion::Components::ComponentModule |
| In: |
lib/adhearsion/component_manager.rb
|
| Parent: | Module |
| new | -> | load |
| component | [R] | Creates new Script, and loads main_file in the scope of the Script. If a block is given, the script is passed to it before loading from the file, and constants can be defined as inputs to the script. |
| dir | [R] | The directory in which main_file is located, and relative to which load searches for files before falling back to Kernel#load. |
| loaded_features | [R] | A hash that maps filename=>true for each file that has been required locally by the script. This has the same semantics as $", alias $LOADED_FEATURES, except that it is local to this script. |
| main_file | [R] | The file with which the Script was instantiated. |
Loads file into this Script. Searches relative to the local dir, that is, the dir of the file given in the original call to Script.load(file), loads the file, if found, into this Script‘s scope, and returns true. If the file is not found, falls back to Kernel.load, which searches on $LOAD_PATH, loads the file, if found, into global scope, and returns true. Otherwise, raises LoadError.
The wrap argument is passed to Kernel.load in the fallback case, when the file is not found locally.
Typically called from within the main file to load additional sub files, or from those sub files.
Analogous to Kernel#require. First tries the local dir, then falls back to Kernel#require. Will load a given feature only once.
Note that extensions (*.so, *.dll) can be required in the global scope, as usual, but not in the local scope. (This is not much of a limitation in practice—you wouldn‘t want to load an extension more than once.) This implementation falls back to Kernel#require when the argument is an extension or is not found locally.