lib/outpost/model/authorization.rb in outpost-cms-0.0.3 vs lib/outpost/model/authorization.rb in outpost-cms-0.0.4
- old
+ new
@@ -5,10 +5,11 @@
included do
has_many :user_permissions
has_many :permissions, through: :user_permissions
end
+
# Check if a user can manage the passed-in resource(s)
#
# If multiple resources are passed in, a user must be
# allowed to manage ALL of them in order for this to
# return true.
@@ -17,11 +18,9 @@
#
def can_manage?(*resources)
self.is_superuser? or (allowed_resources & resources) == resources
end
- #
-
def allowed_resources
@allowed_resources ||= begin
p = self.is_superuser? ? Permission.all : self.permissions
p.map { |p| p.resource.safe_constantize }.compact
end