From 90da4c70bb7cc80b524d3913e9e2d04408b591cd Mon Sep 17 00:00:00 2001 From: Luke Miller Date: Mon, 19 Apr 2021 10:11:22 -0400 Subject: [PATCH] standardizing org template --- modpol/orgs/orgs.lua | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/modpol/orgs/orgs.lua b/modpol/orgs/orgs.lua index d8db2ad..fbc6668 100644 --- a/modpol/orgs/orgs.lua +++ b/modpol/orgs/orgs.lua @@ -7,6 +7,18 @@ modpol.orgs = -- sets modpol.orgs as its own fallback modpol.orgs.__index = modpol.orgs +function temp_org() + return { + id = nil, + name = nil, + policies = {}, + processes = {}, + members = {}, + parent = nil, + children = {} + } +end + -- ================================================== -- returns org when given its id or name function modpol.orgs.get_org(arg) @@ -74,17 +86,10 @@ function modpol.orgs.init_instance() return false, error_msg end - local instance = { - id = 1, - name = "instance", - policies = {}, - members = {}, - ledger = {}, - parent = nil, - children = {}, - properties = {}, - old_names = {} - } + local instance = temp_org() + instance.id = 1 + instance.name = "instance" + setmetatable(instance, modpol.orgs) -- adding instance to org list @@ -146,14 +151,11 @@ function modpol.orgs:add_org(name) -- creating the child sub org modpol.orgs.count = modpol.orgs.count + 1 - local child_org = { - id = modpol.orgs.count, - name = name, - policies = {}, - members = {}, - parent = self.id, - children = {}, - } + local child_org = temp_org() + child_org.id = modpol.orgs.count + child_org.name = name + child_org.parent = self.id + setmetatable(child_org, modpol.orgs) -- adding child id to list of children