Added Ldoc comments for interactions and orgs.process.lua

This commit is contained in:
SkylarHew
2022-01-10 17:27:27 -07:00
parent 4052fa4b55
commit 5085d87f68
2 changed files with 71 additions and 28 deletions

View File

@ -1,5 +1,12 @@
--- Process functions for orgs
-- @module modpol.orgs.process
--- Call modules
-- @function modpol.orgs.call_module
-- @param module_slug Same as module name
-- @param intiator Initiator for module
-- @param config Config for module
-- @param result
function modpol.orgs:call_module(module_slug, initiator, config, result)
if not modpol.modules[module_slug] then
modpol.ocutil.log('Error in ' .. self.name .. ':call_module -> module "' .. module_slug .. '" not found')
@ -53,10 +60,18 @@ function modpol.orgs:call_module(module_slug, initiator, config, result)
return index
end
--- Delete process by id
-- @function modpol.orgs:delete_process
-- @param id Id of process
function modpol.orgs:delete_process(id)
self.processes[id] = 'deleted'
end
--- Add a new pending action
-- @function modpol.orgs:add_pending_action
-- @param process_id Process id
-- @param user User adding the action
-- @param callback
function modpol.orgs:add_pending_action(process_id, user, callback)
self.pending[user] = self.pending[user] or {}
self.pending[user][process_id] = callback
@ -64,18 +79,29 @@ function modpol.orgs:add_pending_action(process_id, user, callback)
user, "New pending action in org "..self.name)
end
--- Remove a pending action
-- @function modpol.orgs:remove_pending_action
-- @param process_id Process id to be removed
-- @param user
function modpol.orgs:remove_pending_action(process_id, user)
if self.pending[user] then
self.pending[user][process_id] = nil
end
end
--- Wipe all pending actions for process
-- @function modpol.orgs:wipe_pending_actions
-- @param process_id
function modpol.orgs:wipe_pending_actions(process_id)
for user in pairs(self.pending) do
self.pending[user][process_id] = nil
end
end
--- Check if there are pending actions for user
-- @function modpol.orgs:has_pending_actions
-- @param user User
-- @return True if there are pending actions for a user, false if not
function modpol.orgs:has_pending_actions(user)
-- next() will return the next pair in a table
-- if next() returns nil, the table is empty
@ -90,6 +116,10 @@ function modpol.orgs:has_pending_actions(user)
end
end
--- Interact a user with given process
-- @function modpol.orgs:interact
-- @param process_id
-- @param user
function modpol.orgs:interact(process_id, user)
local process = self.processes[process_id]
if self.pending[user] then