Skip to content

Commit

Permalink
chore: use Kernel.raise in behaviours
Browse files Browse the repository at this point in the history
To avoid dealing with overriden #raise
  • Loading branch information
palkan committed Sep 2, 2021
1 parent 4e7cd6d commit ad92f07
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/action_policy/behaviour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def authorization_rule_for(policy, rule)

def lookup_authorization_policy(record, **options) # :nodoc:
record = implicit_authorization_target! if :__undef__ == record # rubocop:disable Style/YodaCondition See https://github.com/palkan/action_policy/pull/180
raise ArgumentError, "Record must be specified" if record.nil?
Kernel.raise ArgumentError, "Record must be specified" if record.nil?

policy_for(record: record, **options)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/action_policy/behaviours/policy_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def policy_for(record:, with: nil, namespace: authorization_namespace, context:
end

def authorization_context
raise NotImplementedError, "Please, define `authorization_context` method!"
Kernel.raise NotImplementedError, "Please, define `authorization_context` method!"
end

def authorization_namespace
Expand All @@ -45,7 +45,7 @@ def implicit_authorization_target

# Return implicit authorization target or raises an exception if it's nil
def implicit_authorization_target!
implicit_authorization_target || raise(
implicit_authorization_target || Kernel.raise(
NotFound,
[
self,
Expand Down
2 changes: 1 addition & 1 deletion lib/action_policy/rails/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def implicit_authorization_target
end

def verify_authorized
raise UnauthorizedAction.new(controller_path, action_name) if
Kernel.raise UnauthorizedAction.new(controller_path, action_name) if
authorize_count.zero? && !verify_authorized_skipped
end

Expand Down

0 comments on commit ad92f07

Please sign in to comment.