Software /
code /
prosody
Diff
core/moduleapi.lua @ 5526:d54011a23b20
moduleapi: Add module:context(host) to produce a fake API context for a given host (or global). module:context("*"):get_option("foo") to get global options.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 27 Apr 2013 14:57:24 +0100 |
parent | 5498:2a67235e1d4d |
child | 5527:7e7f45f587a1 |
line wrap: on
line diff
--- a/core/moduleapi.lua Sat Apr 27 13:11:03 2013 +0100 +++ b/core/moduleapi.lua Sat Apr 27 14:57:24 2013 +0100 @@ -270,6 +270,10 @@ return set.new(value); end +function api:context(host) + return setmetatable({host=host or "*"}, {__index=self,__newindex=self}); +end + function api:add_item(key, value) self.items = self.items or {}; self.items[key] = self.items[key] or {};