Module: Outpost::Model::Authorization
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/outpost/model/authorization.rb
Instance Method Summary collapse
- #allowed_resources ⇒ Object
-
#can_manage?(*resources) ⇒ Boolean
Check if a user can manage the passed-in resource(s).
Instance Method Details
#allowed_resources ⇒ Object
23 24 25 26 27 28 |
# File 'lib/outpost/model/authorization.rb', line 23 def allowed_resources @allowed_resources ||= begin p = self.is_superuser? ? Permission.all : self. p.map { |p| p.resource.safe_constantize }.compact end end |
#can_manage?(*resources) ⇒ Boolean
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.
19 20 21 |
# File 'lib/outpost/model/authorization.rb', line 19 def can_manage?(*resources) self.is_superuser? or (allowed_resources & resources) == resources end |