Class: Thredded::MessageboardPolicy::Scope
- Inherits:
-
Object
- Object
- Thredded::MessageboardPolicy::Scope
- Defined in:
- app/policies/thredded/messageboard_policy.rb
Overview
The scope of readable messageboards
Instance Method Summary collapse
-
#initialize(user, scope) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ ActiveRecord::Relation<Thredded::Messageboards>
Constructor Details
#initialize(user, scope) ⇒ Scope
Returns a new instance of Scope.
9 10 11 12 |
# File 'app/policies/thredded/messageboard_policy.rb', line 9 def initialize(user, scope) @user = user @scope = scope end |
Instance Method Details
#resolve ⇒ ActiveRecord::Relation<Thredded::Messageboards>
15 16 17 18 19 20 21 22 |
# File 'app/policies/thredded/messageboard_policy.rb', line 15 def resolve readable = @user. if readable == Thredded::Messageboard.all @scope else @scope.merge(readable) end end |