module Pundit
Constants
- VERSION
Attributes
policy[W]
policy_scope[W]
Public Class Methods
policy(user, record)
click to toggle source
# File lib/pundit.rb, line 26 def policy(user, record) policy = PolicyFinder.new(record).policy policy.new(user, record) if policy end
policy!(user, record)
click to toggle source
# File lib/pundit.rb, line 31 def policy!(user, record) PolicyFinder.new(record).policy!.new(user, record) end
policy_scope(user, scope)
click to toggle source
# File lib/pundit.rb, line 17 def policy_scope(user, scope) policy_scope = PolicyFinder.new(scope).scope policy_scope.new(user, scope).resolve if policy_scope end
policy_scope!(user, scope)
click to toggle source
# File lib/pundit.rb, line 22 def policy_scope!(user, scope) PolicyFinder.new(scope).scope!.new(user, scope).resolve end
Public Instance Methods
policy(record)
click to toggle source
# File lib/pundit.rb, line 83 def policy(record) @policy or Pundit.policy!(pundit_user, record) end
policy_scope(scope)
click to toggle source
# File lib/pundit.rb, line 77 def policy_scope(scope) @_policy_scoped = true @policy_scope or Pundit.policy_scope!(pundit_user, scope) end
pundit_user()
click to toggle source
# File lib/pundit.rb, line 88 def pundit_user current_user end
verify_policy_scoped()
click to toggle source
# File lib/pundit.rb, line 58 def verify_policy_scoped raise AuthorizationNotPerformedError unless @_policy_scoped end