diff options
author | Kim Alvefur <zash@zash.se> | 2013-04-27 19:14:22 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-04-27 19:14:22 +0200 |
commit | 3e21305cb4a3ecbab4987883b6dfaac6f86b2906 (patch) | |
tree | a86e223e031f577303923a4fbb03073887c012aa /core/moduleapi.lua | |
parent | 5c29384f6470efeb72236b9c3f01df9d78493891 (diff) | |
download | prosody-3e21305cb4a3ecbab4987883b6dfaac6f86b2906.tar.gz prosody-3e21305cb4a3ecbab4987883b6dfaac6f86b2906.zip |
moduleapi: module:provides called without an item makes a copy of the environment instead. Fixes warnings about non-existent globals
Diffstat (limited to 'core/moduleapi.lua')
-rw-r--r-- | core/moduleapi.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua index 9baf4fba..764ed52a 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -319,7 +319,13 @@ function api:handle_items(type, added_cb, removed_cb, existing) end function api:provides(name, item) - if not item then item = self.environment; end + -- if not item then item = setmetatable({}, { __index = function(t,k) return rawget(self.environment, k); end }); end + if not item then + item = {} + for k,v in pairs(self.environment) do + if k ~= "module" then item[k] = v; end + end + end if not item.name then local item_name = self.name; -- Strip a provider prefix to find the item name |