Changeset

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
parents 5524:e9090966c803
children 5527:7e7f45f587a1
files core/moduleapi.lua
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
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 {};