Skip to content

Commit

Permalink
Rename authorize and policy
Browse files Browse the repository at this point in the history
  • Loading branch information
wilddima committed Mar 2, 2018
1 parent c8acf28 commit 08deb29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/pundit_namespaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def self.included(base)
base.class_eval do
helper PunditNamespaces::Helpers if respond_to?(:helper)
if respond_to?(:helper_method)
helper_method :policy
helper_method :pundit_namespace_matcher
helper_method :pundit_user
helper_method :authorize_all
helper_method :policies
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pundit_namespaces/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module PunditNamespaces
module Helpers
class UndefinedMatcherError < StandardError; end

def authorize(user, record, query)
def authorize_all(user, record, query)
policy_namespaces(user, record).each do |policy|
unless policy[:policy_obj].public_send(query)
raise policy[:error], query: query, record: record, policy: policy
Expand All @@ -12,7 +12,7 @@ def authorize(user, record, query)
record
end

def policy(user, record)
def all_policies(user, record)
policy_namespaces(user, record)
.map { |policy| policy[:policy_obj] }
end
Expand Down

0 comments on commit 08deb29

Please sign in to comment.