moduleapi: Add module:context(host) to produce a fake API context for a given host...
authorMatthew Wild <mwild1@gmail.com>
Sat, 27 Apr 2013 13:57:24 +0000 (14:57 +0100)
committerMatthew Wild <mwild1@gmail.com>
Sat, 27 Apr 2013 13:57:24 +0000 (14:57 +0100)
core/moduleapi.lua

index 30360f73547354afc245f2f2065ed35573f2ad02..da44db5ff9147ddc0fbe9bfaa053d9134b881d2a 100644 (file)
@@ -270,6 +270,10 @@ function api:get_option_set(name, ...)
        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 {};