lib/pundit.rb in pundit-0.2.0 vs lib/pundit.rb in pundit-0.2.1
- old
+ new
@@ -33,25 +33,35 @@
included do
if respond_to?(:helper_method)
helper_method :policy_scope
helper_method :policy
end
+ if respond_to?(:hide_action)
+ hide_action :authorize
+ hide_action :verify_authorized
+ hide_action :verify_policy_scoped
+ end
end
def verify_authorized
raise NotAuthorizedError unless @_policy_authorized
end
+ def verify_policy_scoped
+ raise NotAuthorizedError unless @_policy_scoped
+ end
+
def authorize(record, query=nil)
query ||= params[:action].to_s + "?"
@_policy_authorized = true
unless policy(record).public_send(query)
raise NotAuthorizedError, "not allowed to #{query} this #{record}"
end
true
end
def policy_scope(scope)
+ @_policy_scoped = true
Pundit.policy_scope!(current_user, scope)
end
def policy(record)
Pundit.policy!(current_user, record)