Module: ActionPolicy::Testing::AuthorizeTracker
- Defined in:
- lib/action_policy/testing.rb
Overview
Collects all Authorizer calls
Defined Under Namespace
Modules: Context Classes: Call, Scoping
Class Method Summary collapse
- .calls ⇒ Object
- .scopings ⇒ Object
-
.track(policy, rule) ⇒ Object
Called from Authorizer.
-
.track_scope(target, policy, type:, name:, scope_options:) ⇒ Object
Called from Authorizer.
-
.tracking ⇒ Object
Wrap code under inspection into this method to track authorize! calls.
- .tracking? ⇒ Boolean
Class Method Details
.calls ⇒ Object
105 106 107 |
# File 'lib/action_policy/testing.rb', line 105 def calls Thread.current[:__action_policy_calls] ||= [] end |
.scopings ⇒ Object
109 110 111 |
# File 'lib/action_policy/testing.rb', line 109 def scopings Thread.current[:__action_policy_scopings] ||= [] end |
.track(policy, rule) ⇒ Object
Called from Authorizer
94 95 96 97 |
# File 'lib/action_policy/testing.rb', line 94 def track(policy, rule) return unless tracking? calls << Call.new(policy, rule) end |
.track_scope(target, policy, type:, name:, scope_options:) ⇒ Object
Called from Authorizer
100 101 102 103 |
# File 'lib/action_policy/testing.rb', line 100 def track_scope(target, policy, type:, name:, scope_options:) return unless tracking? scopings << Scoping.new(policy, target, type, name, ) end |
.tracking ⇒ Object
Wrap code under inspection into this method to track authorize! calls
84 85 86 87 88 89 90 91 |
# File 'lib/action_policy/testing.rb', line 84 def tracking calls.clear scopings.clear Thread.current[:__action_policy_tracking] = true yield ensure Thread.current[:__action_policy_tracking] = false end |
.tracking? ⇒ Boolean
113 114 115 |
# File 'lib/action_policy/testing.rb', line 113 def tracking? Thread.current[:__action_policy_tracking] == true end |