Comparison

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
comparison
equal deleted inserted replaced
5524:e9090966c803 5526:d54011a23b20
268 end 268 end
269 269
270 return set.new(value); 270 return set.new(value);
271 end 271 end
272 272
273 function api:context(host)
274 return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
275 end
276
273 function api:add_item(key, value) 277 function api:add_item(key, value)
274 self.items = self.items or {}; 278 self.items = self.items or {};
275 self.items[key] = self.items[key] or {}; 279 self.items[key] = self.items[key] or {};
276 t_insert(self.items[key], value); 280 t_insert(self.items[key], value);
277 self:fire_event("item-added/"..key, {source = self, item = value}); 281 self:fire_event("item-added/"..key, {source = self, item = value});