Browse Source

failsafe for empty orgs.array

Luke Miller 3 năm trước cách đây
mục cha
commit
e22b143a6a
1 tập tin đã thay đổi với 11 bổ sung3 xóa
  1. 11 3
      modpol/modpol.lua

+ 11 - 3
modpol/modpol.lua

@@ -71,9 +71,17 @@ dofile (topdir .. "/api.lua")
 
 -- ===================================================================
 -- Final checks
-for id, org in ipairs(modpol.orgs.array) do
-    if type(org) == 'table' then 
-        setmetatable(org, modpol.orgs)
+
+-- sets org metatable on load
+if (modpol.orgs.array) then
+    for id, org in ipairs(modpol.orgs.array) do
+        if type(org) == 'table' then 
+            setmetatable(org, modpol.orgs)
+        end
+        -- sets process metatable on load
+        for id, process in ipairs(org.processes) do
+            setmetatable(process, org.modules[process.type])
+        end
     end
 end