Class: ActionPolicy::Testing::AuthorizeTracker::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/action_policy/testing.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(policy, rule) ⇒ Call

Returns a new instance of Call.



11
12
13
14
# File 'lib/action_policy/testing.rb', line 11

def initialize(policy, rule)
  @policy = policy
  @rule = rule
end

Instance Attribute Details

#policyObject (readonly)

Returns the value of attribute policy.



9
10
11
# File 'lib/action_policy/testing.rb', line 9

def policy
  @policy
end

#ruleObject (readonly)

Returns the value of attribute rule.



9
10
11
# File 'lib/action_policy/testing.rb', line 9

def rule
  @rule
end

Instance Method Details

#inspectObject



22
23
24
25
# File 'lib/action_policy/testing.rb', line 22

def inspect
  "#{policy.record.inspect} was authorized with #{policy.class}##{rule} " \
    "and context #{policy.authorization_context.inspect}"
end

#matches?(policy_class, actual_rule, target, context) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/action_policy/testing.rb', line 16

def matches?(policy_class, actual_rule, target, context)
  policy_class == policy.class &&
    (target.is_a?(Class) ? target == policy.record : target === policy.record) &&
    rule == actual_rule && context_matches?(context, policy.authorization_context)
end