module Pundit
Constants
- SUFFIX
- VERSION
Public Class Methods
policy(user, record)
click to toggle source
# File lib/pundit.rb, line 56 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 61 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 47 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 52 def policy_scope!(user, scope) PolicyFinder.new(scope).scope!.new(user, scope).resolve end
Public Instance Methods
permitted_attributes(record)
click to toggle source
# File lib/pundit.rb, line 140 def permitted_attributes(record) name = record.class.to_s.demodulize.underscore params.require(name).permit(policy(record).permitted_attributes) end
policies()
click to toggle source
# File lib/pundit.rb, line 145 def policies @_pundit_policies ||= {} end
policy(record)
click to toggle source
# File lib/pundit.rb, line 136 def policy(record) policies[record] ||= Pundit.policy!(pundit_user, record) end
policy_scope(scope)
click to toggle source
# File lib/pundit.rb, line 131 def policy_scope(scope) @_pundit_policy_scoped = true pundit_policy_scope(scope) end
policy_scopes()
click to toggle source
# File lib/pundit.rb, line 149 def policy_scopes @_pundit_policy_scopes ||= {} end
pundit_policy_scoped?()
click to toggle source
# File lib/pundit.rb, line 98 def pundit_policy_scoped? !!@_pundit_policy_scoped end
pundit_user()
click to toggle source
# File lib/pundit.rb, line 153 def pundit_user current_user end
skip_policy_scope()
click to toggle source
# File lib/pundit.rb, line 127 def skip_policy_scope @_pundit_policy_scoped = true end
verify_policy_scoped()
click to toggle source
# File lib/pundit.rb, line 106 def verify_policy_scoped raise PolicyScopingNotPerformedError unless pundit_policy_scoped? end
Private Instance Methods
pundit_policy_scope(scope)
click to toggle source
# File lib/pundit.rb, line 159 def pundit_policy_scope(scope) policy_scopes[scope] ||= Pundit.policy_scope!(pundit_user, scope) end