Class: Thredded::MessageboardPolicy::Scope

Inherits:
Object
  • Object
show all
Defined in:
app/policies/thredded/messageboard_policy.rb

Overview

The scope of readable messageboards

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Returns a new instance of Scope.

Parameters:


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

#resolveActiveRecord::Relation<Thredded::Messageboards>

Returns:

  • (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.thredded_can_read_messageboards
  if readable == Thredded::Messageboard.all
    @scope
  else
    @scope.merge(readable)
  end
end