Class: RolePolicy::Scope
- Inherits:
-
Object
- Object
- RolePolicy::Scope
- Defined in:
- app/policies/role_policy.rb
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.
5 6 7 8 |
# File 'app/policies/role_policy.rb', line 5 def initialize(user, scope) @user = user @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
3 4 5 |
# File 'app/policies/role_policy.rb', line 3 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'app/policies/role_policy.rb', line 3 def user @user end |
Instance Method Details
#resolve ⇒ Object
10 11 12 |
# File 'app/policies/role_policy.rb', line 10 def resolve user&.is_administrator? ? scope : scope.where(name: [:member, :contributor]) end |