Software /
code /
prosody
Changeset
5529:af58eea131b4
moduleapi: module:provides called without an item makes a copy of the environment instead. Fixes warnings about non-existent globals
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Apr 2013 19:14:22 +0200 |
parents | 5527:7e7f45f587a1 |
children | 5530:d83482fc4a81 |
files | core/moduleapi.lua |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Sat Apr 27 14:59:00 2013 +0100 +++ b/core/moduleapi.lua Sat Apr 27 19:14:22 2013 +0200 @@ -319,7 +319,13 @@ 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