Software /
code /
prosody
Diff
core/moduleapi.lua @ 5527:7e7f45f587a1
moduleapi: Add module:get_option_inherited_set() to return a set that inherits items from a globally set set, if set
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 27 Apr 2013 14:59:00 +0100 |
parent | 5526:d54011a23b20 |
child | 5529:af58eea131b4 |
line wrap: on
line diff
--- a/core/moduleapi.lua Sat Apr 27 14:57:24 2013 +0100 +++ b/core/moduleapi.lua Sat Apr 27 14:59:00 2013 +0100 @@ -270,6 +270,18 @@ 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