Class: HunterPolicy::Scope
- Inherits:
-
Scope
- Object
- Scope
- HunterPolicy::Scope
- Defined in:
- app/policies/hunter_policy.rb
Overview
When working with a list of records, this class can limit access
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, scope) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ Object
Constructor Details
#initialize(user, scope) ⇒ Scope
Returns a new instance of Scope.
24 25 26 27 |
# File 'app/policies/hunter_policy.rb', line 24 def initialize(user, scope) @user = user @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope
22 23 24 |
# File 'app/policies/hunter_policy.rb', line 22 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user
22 23 24 |
# File 'app/policies/hunter_policy.rb', line 22 def user @user end |
Instance Method Details
#resolve ⇒ Object
29 30 31 32 |
# File 'app/policies/hunter_policy.rb', line 29 def resolve return scope.none if @user.nil? scope.all end |