module Pundit::Authorization

def authorize(record, query = nil, policy_class: nil)

Returns:
  • (Object) - Always returns the passed object record

Raises:
  • (NotAuthorizedError) - if the given query method returned false

Parameters:
  • policy_class (Class) -- the policy class we want to force use of
  • query (Symbol, String) -- the predicate method to check on the policy (e.g. `:show?`).
  • record (Object, Array) -- the object we're checking permissions of
def authorize(record, query = nil, policy_class: nil)
  query ||= "#{action_name}?"
  @_pundit_policy_authorized = true
  Pundit.authorize(pundit_user, record, query, policy_class: policy_class, cache: policies)
end