moduleapi: module:provides called without an item makes a copy of the environment...
authorKim Alvefur <zash@zash.se>
Sat, 27 Apr 2013 17:14:22 +0000 (19:14 +0200)
committerKim Alvefur <zash@zash.se>
Sat, 27 Apr 2013 17:14:22 +0000 (19:14 +0200)
core/moduleapi.lua

index 9baf4fbaa4549e03d8edf2a8f7b575fb93ad8521..764ed52ae63667e6c1e686594867b8d168f9e905 100644 (file)
@@ -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