The Dongle Module system provides a very simple capability for inheritance and ownership within Dongle addons. Each new module is actually a full-fledged dongle object, with the caveat that its initialization and enable functions aren't called until after its parent, and the disable function is called before it's parent.
This API was introduced with Dongle-1.0
DongleObject:NewModule(name[, obj])[]
Creates a new dongle object, as a module of this DongleObject.
Arguments[]
- name (string) - The name of the dongle object. This must be a unique name in the global dongle registry.
- obj (table) - An optional object to use as the base for the new dongle object.
Returns[]
- obj (table) - The dongle object with all injected functions
- name (string) - The name of the dongle object
Behavior[]
The module will not have its :Intitialize() or :Enable() methods called until DongleObject's methods have been called. The :Disable() method of the module will be called prior to the :Disable() method of the DongleObject.
DongleObject:HasModule(module)[]
Returns true if the given DongleObject has a module matching the given argument, this can be used to get a module by name.
Argument[]
- module (string, table) - The name of a module, or the module object itself
Returns[]
- module if it exists nil otherwise
DongleObject:IterateModules()[]
Returns[]
- ModuleIterator (function) - An iterator over the modules of the DongleObject
Iterator Returns[]
- name (string) - The name of the module
- obj (table) - The module's object