Diff

util/pubsub.lua @ 4099:5c0b7947f0ef

util.pubsub: Some tidying/optimisation to service:may()
author Matthew Wild <mwild1@gmail.com>
date Sat, 08 Jan 2011 23:15:27 +0000
parent 3945:39e34cb4c491
child 4100:69e3f1e7111e
line wrap: on
line diff
--- a/util/pubsub.lua	Sat Jan 08 09:09:19 2011 +0100
+++ b/util/pubsub.lua	Sat Jan 08 23:15:27 2011 +0000
@@ -27,17 +27,14 @@
 function service:may(node, actor, action)
 	if actor == true then return true; end
 	
-	
 	local node_obj = self.nodes[node];
 	local node_aff = node_obj and node_obj.affiliations[actor];
 	local service_aff = self.affiliations[actor]
 	                 or self.config.get_affiliation(actor, node, action)
 	                 or "none";
 	
+	-- Check if node allows/forbids it
 	local node_capabilities = node_obj and node_obj.capabilities;
-	local service_capabilities = self.config.capabilities;
-	
-	-- Check if node allows/forbids it	
 	if node_capabilities then
 		local caps = node_capabilities[node_aff or service_aff];
 		if caps then
@@ -47,7 +44,9 @@
 			end
 		end
 	end
+	
 	-- Check service-wide capabilities instead
+	local service_capabilities = self.config.capabilities;
 	local caps = service_capabilities[node_aff or service_aff];
 	if caps then
 		local can = caps[action];