lib/action_policy/behaviour.rb in action_policy-0.3.0 vs lib/action_policy/behaviour.rb in action_policy-0.3.1
- old
+ new
@@ -33,11 +33,11 @@
# Policy is inferred from record
# (unless explicitly specified through `with` option).
#
# Raises `ActionPolicy::Unauthorized` if check failed.
def authorize!(record = :__undef__, to:, **options)
- record = implicit_authorization_target if record == :__undef__
+ record = implicit_authorization_target! if record == :__undef__
raise ArgumentError, "Record must be specified" if record.nil?
policy = policy_for(record: record, **options)
Authorizer.call(policy, authorization_rule_for(policy, to))
@@ -45,10 +45,10 @@
# Checks that an activity is allowed for the current context (e.g. user).
#
# Returns true of false.
def allowed_to?(rule, record = :__undef__, **options)
- record = implicit_authorization_target if record == :__undef__
+ record = implicit_authorization_target! if record == :__undef__
raise ArgumentError, "Record must be specified" if record.nil?
policy = policy_for(record: record, **options)
policy.apply(authorization_rule_for(policy, rule))