Module: ActionPolicy::Policy::Authorization
- Included in:
- Base
- Defined in:
- lib/action_policy/policy/authorization.rb
Overview
Authorization context could include multiple parameters.
It is possible to provide more verificatio contexts, by specifying them in the policy and providing them at the authorization step.
For example:
class ApplicationPolicy < ActionPolicy::Base
# Add user and account to the context; it's required to be passed
# to a policy constructor and be not nil
:user, :account
# you can skip non-nil check if you want
# authorize :account, allow_nil: true
def manage?
# available as a simple accessor
account.enabled?
end
end
ApplicantPolicy.new(user: user, account: account)
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Instance Attribute Summary collapse
-
#authorization_context ⇒ Object
readonly
Returns the value of attribute authorization_context.
Class Method Summary collapse
- .prepended(base) ⇒ Object (also: included)
Instance Attribute Details
#authorization_context ⇒ Object (readonly)
Returns the value of attribute authorization_context.
47 48 49 |
# File 'lib/action_policy/policy/authorization.rb', line 47 def @authorization_context end |
Class Method Details
.prepended(base) ⇒ Object Also known as: included
39 40 41 42 |
# File 'lib/action_policy/policy/authorization.rb', line 39 def prepended(base) base.extend ClassMethods base.prepend InstanceMethods end |