Module: ActionPolicy::Behaviour::ClassMethods
- Defined in:
- lib/action_policy/behaviour.rb
Overview
:nodoc:
Instance Method Summary collapse
- #authorization_targets ⇒ Object
-
#authorize(key, through: nil) ⇒ Object
Configure authorization context.
Instance Method Details
#authorization_targets ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/action_policy/behaviour.rb', line 112 def return @authorization_targets if instance_variable_defined?(:@authorization_targets) @authorization_targets = if superclass.respond_to?(:authorization_targets) superclass..dup else {} end end |
#authorize(key, through: nil) ⇒ Object
Configure authorization context.
For example:
class ApplicationController < ActionController::Base
# Pass the value of `current_user` to authorization as `user`
:user, through: :current_user
end
# Assuming that in your ApplicationPolicy
class ApplicationPolicy < ActionPolicy::Base
:user
end
107 108 109 110 |
# File 'lib/action_policy/behaviour.rb', line 107 def (key, through: nil) method_or_proc = through || key [key] = method_or_proc end |