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
110 111 112 113 114 115 116 117 118 |
# File 'lib/action_policy/behaviour.rb', line 110 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
105 106 107 108 |
# File 'lib/action_policy/behaviour.rb', line 105 def (key, through: nil) meth = through || key [key] = meth end |