aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-04-27 14:59:00 +0100
committerMatthew Wild <mwild1@gmail.com>2013-04-27 14:59:00 +0100
commit5c29384f6470efeb72236b9c3f01df9d78493891 (patch)
tree2d67224cca878b9859de4556ff2e196310e9b23b /core
parentead3f6fad6b2d8428b292811cfcbad23981d3b1a (diff)
downloadprosody-5c29384f6470efeb72236b9c3f01df9d78493891.tar.gz
prosody-5c29384f6470efeb72236b9c3f01df9d78493891.zip
moduleapi: Add module:get_option_inherited_set() to return a set that inherits items from a globally set set, if set
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index da44db5f..9baf4fba 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -270,6 +270,18 @@ function api:get_option_set(name, ...)
return set.new(value);
end
+function api:get_option_inherited_set(name, ...)
+ local value = self:get_option_set(name, ...);
+ local global_value = self:context("*"):get_option_set(name, ...);
+ if not value then
+ return global_value;
+ elseif not global_value then
+ return value;
+ end
+ value:include(global_value);
+ return value;
+end
+
function api:context(host)
return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
end