lib/zen/helper/acl.rb in zen-0.2.3 vs lib/zen/helper/acl.rb in zen-0.2.4
- old
+ new
@@ -82,17 +82,23 @@
# @param [Array] reqs Array of permissions that are required.
# @param [Boolean] require_all Boolean that specifies that the user
# should have ALL specified permissios. Setting this to false causes
# this method to return true if any of the permissions are set for the
# current user.
+ # @param [String] identifier A custom identifier to use for validating the user's
+ # permissions instead of using a class trait.
# @return [Boolean]
#
- def user_authorized?(reqs, require_all = true)
- identifier = ancestral_trait.values_at(:extension_identifier)
- identifier = identifier[0]
-
+ def user_authorized?(reqs, require_all = true, identifier = nil)
+ # Retrieve the identifier from the class trait if we didn't already have one
if identifier.nil?
+ identifier = ancestral_trait.values_at(:extension_identifier)
+ identifier = identifier[0]
+ end
+
+ # Still don't have an identifier?
+ if identifier.nil?
raise "You need to specify an extension identifier"
end
# Get the ACL list
rules = self.extension_permissions
@@ -120,8 +126,9 @@
end
end
return true
end
+
end
end
end