Software /
code /
prosody
Comparison
core/modulemanager.lua @ 5410:bea93cfd6c54
modulemanager: add function to retrieve module items from a specific host entity.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Mon, 01 Apr 2013 22:34:44 +0000 |
parent | 5377:898454038524 |
child | 5411:82b3ddba0ec7 |
comparison
equal
deleted
inserted
replaced
5409:8e98a58ab6a3 | 5410:bea93cfd6c54 |
---|---|
17 local hosts = hosts; | 17 local hosts = hosts; |
18 local prosody = prosody; | 18 local prosody = prosody; |
19 | 19 |
20 local pcall, xpcall = pcall, xpcall; | 20 local pcall, xpcall = pcall, xpcall; |
21 local setmetatable, rawget = setmetatable, rawget; | 21 local setmetatable, rawget = setmetatable, rawget; |
22 local pairs, type, tostring = pairs, type, tostring; | 22 local pairs, type, tostring, t_insert = pairs, type, tostring, table.insert; |
23 | 23 |
24 local debug_traceback = debug.traceback; | 24 local debug_traceback = debug.traceback; |
25 local unpack, select = unpack, select; | 25 local unpack, select = unpack, select; |
26 pcall = function(f, ...) | 26 pcall = function(f, ...) |
27 local n = select("#", ...); | 27 local n = select("#", ...); |
276 | 276 |
277 function get_module(host, name) | 277 function get_module(host, name) |
278 return modulemap[host] and modulemap[host][name]; | 278 return modulemap[host] and modulemap[host][name]; |
279 end | 279 end |
280 | 280 |
281 function get_items(key, host) | |
282 local result = {}; | |
283 local modules = modulemap[host]; | |
284 if not key or not host or not modules then return nil; end | |
285 | |
286 for _, module in pairs(modules) do | |
287 local mod = module.module; | |
288 if mod.items and mod.items[key] then | |
289 for _, value in ipairs(mod.items[key]) do | |
290 t_insert(result, value); | |
291 end | |
292 end | |
293 end | |
294 | |
295 return result; | |
296 end | |
297 | |
281 function get_modules(host) | 298 function get_modules(host) |
282 return modulemap[host]; | 299 return modulemap[host]; |
283 end | 300 end |
284 | 301 |
285 function is_loaded(host, name) | 302 function is_loaded(host, name) |