core/moduleapi.lua
changeset 4613 27fbc9c69eb5
parent 4605 69746db53125
child 4614 20940729c1b4
--- a/core/moduleapi.lua	Wed Mar 14 23:44:24 2012 +0000
+++ b/core/moduleapi.lua	Thu Mar 15 02:52:31 2012 +0000
@@ -292,4 +292,18 @@
 	end
 end
 
+function api:provides(name, item)
+	if not item then item = self.environment; end
+	if not item.name then
+		local item_name = module.name;
+		-- Strip a provider prefix to find the item name
+		-- (e.g. "auth_foo" -> "foo" for an auth provider)
+		if item_name:find(name.."_", 1, true) == 1 then
+			item_name = item_name:sub(#name+2);
+		end
+		item.name = item_name;
+	end
+	self:add_item(name, item);
+end
+
 return api;