mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
parent
66ba305eb8
commit
87d859a3f4
1 changed files with 15 additions and 2 deletions
|
@ -56,10 +56,17 @@ module Pundit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Helper
|
||||||
|
def policy_scope(scope)
|
||||||
|
pundit_policy_scope(scope)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
included do
|
included do
|
||||||
|
helper Helper if respond_to?(:helper)
|
||||||
if respond_to?(:helper_method)
|
if respond_to?(:helper_method)
|
||||||
helper_method :policy_scope
|
|
||||||
helper_method :policy
|
helper_method :policy
|
||||||
|
helper_method :pundit_policy_scope
|
||||||
helper_method :pundit_user
|
helper_method :pundit_user
|
||||||
end
|
end
|
||||||
if respond_to?(:hide_action)
|
if respond_to?(:hide_action)
|
||||||
|
@ -101,7 +108,7 @@ module Pundit
|
||||||
|
|
||||||
def policy_scope(scope)
|
def policy_scope(scope)
|
||||||
@_pundit_policy_scoped = true
|
@_pundit_policy_scoped = true
|
||||||
policy_scopes[scope] ||= Pundit.policy_scope!(pundit_user, scope)
|
pundit_policy_scope(scope)
|
||||||
end
|
end
|
||||||
|
|
||||||
def policy(record)
|
def policy(record)
|
||||||
|
@ -119,4 +126,10 @@ module Pundit
|
||||||
def pundit_user
|
def pundit_user
|
||||||
current_user
|
current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def pundit_policy_scope(scope)
|
||||||
|
policy_scopes[scope] ||= Pundit.policy_scope!(pundit_user, scope)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue