aboutsummaryrefslogtreecommitdiffstats
path: root/core/configmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-01-29 02:13:30 +0000
committerMatthew Wild <mwild1@gmail.com>2009-01-29 02:13:30 +0000
commit609933799faff0ab425cb6188c5716a0333c53d8 (patch)
tree803cdcf8cbb958cc193f355a149fa56e90c595ce /core/configmanager.lua
parentea5fe8c78e3831033a1f763608191cc4edf14412 (diff)
downloadprosody-609933799faff0ab425cb6188c5716a0333c53d8.tar.gz
prosody-609933799faff0ab425cb6188c5716a0333c53d8.zip
configmanager: Add support for defining components
Diffstat (limited to 'core/configmanager.lua')
-rw-r--r--core/configmanager.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/configmanager.lua b/core/configmanager.lua
index a6e86347..a50e7223 100644
--- a/core/configmanager.lua
+++ b/core/configmanager.lua
@@ -107,7 +107,8 @@ do
parsers.lua = {};
function parsers.lua.load(data)
local env;
- env = setmetatable({ Host = true; host = true; }, { __index = function (t, k)
+ -- The ' = true' are needed so as not to set off __newindex when we assign the functions below
+ env = setmetatable({ Host = true; host = true; Component = true, component = true }, { __index = function (t, k)
return rawget(_G, k) or
function (settings_table)
config[__currenthost or "*"][k] = settings_table;
@@ -119,10 +120,21 @@ do
function env.Host(name)
rawset(env, "__currenthost", name);
+ -- Needs at least one setting to logically exist :)
set(name or "*", "core", "defined", true);
end
env.host = env.Host;
+ function env.Component(name)
+ return function (module)
+ set(name, "core", "component_module", module);
+ -- Don't load the global modules by default
+ set(name, "core", "modules_enable", false);
+ rawset(env, "__currenthost", name);
+ end
+ end
+ env.component = env.Component;
+
local chunk, err = loadstring(data);
if not chunk then