module Outpost::Model::Authorization

Public Instance Methods

allowed_resources() click to toggle source
# File lib/outpost/model/authorization.rb, line 23
def allowed_resources
  @allowed_resources ||= begin
    p = self.is_superuser? ? Permission.all : self.permissions
    p.map { |p| p.resource.safe_constantize }.compact
  end
end
can_manage?(*resources) click to toggle source

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.

Constants must be passed in.

# File lib/outpost/model/authorization.rb, line 19
def can_manage?(*resources)
  self.is_superuser? or (allowed_resources & resources) == resources
end