Comparison

core/moduleapi.lua @ 5527:7e7f45f587a1

moduleapi: Add module:get_option_inherited_set() to return a set that inherits items from a globally set set, if set
author Matthew Wild <mwild1@gmail.com>
date Sat, 27 Apr 2013 14:59:00 +0100
parent 5526:d54011a23b20
child 5529:af58eea131b4
comparison
equal deleted inserted replaced
5526:d54011a23b20 5527:7e7f45f587a1
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:get_option_inherited_set(name, ...)
274 local value = self:get_option_set(name, ...);
275 local global_value = self:context("*"):get_option_set(name, ...);
276 if not value then
277 return global_value;
278 elseif not global_value then
279 return value;
280 end
281 value:include(global_value);
282 return value;
283 end
284
273 function api:context(host) 285 function api:context(host)
274 return setmetatable({host=host or "*"}, {__index=self,__newindex=self}); 286 return setmetatable({host=host or "*"}, {__index=self,__newindex=self});
275 end 287 end
276 288
277 function api:add_item(key, value) 289 function api:add_item(key, value)