12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- --- module_template
- -- @module module_template
- --- (Required): data table containing name and description of the module
- -- @field name "Human-readable name (parens OK, no brackets)"
- -- @field slug "Same as module class name"
- -- @field desc "Description of the module"
- -- @field hide "Whether this is a hidden utility module"
- local module_template = {
- name = "Module Human-Readable Name",
- slug = "module_template",
- desc = "Description of the module",
- hide = false;
- }
- --- (Required) Data for module
- -- Variables that module uses during the course of a process
- -- Can be blank
- module_template.data = {
- }
- --- (Required): config for module
- -- Defines the input parameters to the module initiate function.
- -- Can be blank
- -- When calling a module from within another module,
- -- variables not defined in config will be ignored.
- -- Default values set in config can be overridden
- -- @field field_1 ex: votes_required, default = 5
- -- @field field_2 ex: voting_type, default = "majority"
- module_template.config = {
- field_1 = 5
- field_2 = "majority"
- }
- --- (Required): initiate function
- -- Modules have access to the following instance variables:
- -- <li><code>self.org</code> (the org the module was called in),</li>
- -- <li><code>self.initiator</code> (the user that callced the module),</li>
- -- <li><code>self.id</code> (the process id of the module instance)</li>
- -- @param result (optional) Callback if this module is embedded in other modules
- -- @function initiate
- function module_template:initiate(result)
- -- call interaction functions here!
- -- concluding functions:
- -- may need to put result in self.data.result
- -- call this when module is successful (not for abort):
- if result then result() end
- -- call this wherever process might end:
- self.org:delete_process(self.id)
- end
- --- (Required) Add to module table
- modpol.modules.module_template = module_template
|