module Pundit
def policy!(user, record)
-
(Object)
- instance of policy class with query methods
Raises:
-
(InvalidConstructorError)
- if the policy constructor called incorrectly -
(NotDefinedError)
- if the policy cannot be found
Parameters:
-
record
(Object
) -- the object we're retrieving the policy for -
user
(Object
) -- the user that initiated the action
Other tags:
- See: https://github.com/varvet/pundit#policies -
def policy!(user, record) policy = PolicyFinder.new(record).policy! policy.new(user, pundit_model(record)) rescue ArgumentError raise InvalidConstructorError, "Invalid #<#{policy}> constructor is called" end