The main entry point of the library, through which one can access anything else.
The Locator class, which BtUtils is an instance of, is itself defined within this module, in order to not creator another dependency that needs to be handled through something other than a Locator.
||Locatable modules and classes.
Locatable modules and classes.
Instances of this class have a specified set of key-path pairs, so called locators.
The keys are accessible as regular fields of a table, however their value is retrieved by reading and evaluating a lua file defined by the locator. This process is done only once, when the key is first accessed, as the resulting module/class is stored directly on the instance as a regular field.
Locator:Assign (key, creator)
Assigns a value to the specified key if it is still
This method is supplied in order to support the idiom
l.key = l.key or ... in the located modules that intend to directly place themselves into specific a Locator. This idiom would not work as it would recursively invoke the file execution, resulting in an error.
the key to assign under
closure which creates the module/class that belongs to the key
the newly creator module/class if the key was not assigned to, current occupant of the key otherwise
Locator:New (t, locators, prefix)
Creates a new Locator.
locators mapping is a live table, so any changes to it end up affecting Locators functionality. That also relates to the possiblity of not defining it at the time of creating the Locator, but by adding entries to the table returned as a second return value.
preexisting table to convert into a Locator or
table mapping keys to relative paths (without the extension
.lua) where to look for lua scripts defining the modules/classes or
directory prefix to where the path of the Locator is supposed to be with respect to the BtUtils root directory or
locators parameter if specified or a new empty table that is used as the mapping
Removes currently located modules and classes.
That causes them to be reloaded when accessed again, hence the name.