Class: ActionPolicy::TestHelper::WithScopeTarget
- Inherits:
-
Object
- Object
- ActionPolicy::TestHelper::WithScopeTarget
- Defined in:
- lib/action_policy/test_helper.rb
Instance Attribute Summary collapse
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
Instance Method Summary collapse
-
#initialize(scopes) ⇒ WithScopeTarget
constructor
A new instance of WithScopeTarget.
- #with_target {|scopes.first.target| ... } ⇒ Object
Constructor Details
#initialize(scopes) ⇒ WithScopeTarget
Returns a new instance of WithScopeTarget.
11 12 13 |
# File 'lib/action_policy/test_helper.rb', line 11 def initialize(scopes) @scopes = scopes end |
Instance Attribute Details
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
9 10 11 |
# File 'lib/action_policy/test_helper.rb', line 9 def scopes @scopes end |
Instance Method Details
#with_target {|scopes.first.target| ... } ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/action_policy/test_helper.rb', line 15 def with_target if scopes.size > 1 raise "Too many matching scopings (#{scopes.size}), " \ "you can run `.with_target` only when there is the only one match" end yield scopes.first.target end |