# HG changeset patch # User Matthew Wild # Date 1367071044 -3600 # Node ID d54011a23b201715d86f45b5f4d807bede6cd9f7 # Parent e9090966c80313589239d652b14c761c801e0ae6 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. diff -r e9090966c803 -r d54011a23b20 core/moduleapi.lua --- 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 {};