Class: Thredded::MessageboardPolicy

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

Defined Under Namespace

Classes: Scope

Instance Method Summary collapse

Constructor Details

#initialize(user, messageboard) ⇒ MessageboardPolicy

Returns a new instance of MessageboardPolicy.

Parameters:



22
23
24
25
# File 'app/policies/thredded/messageboard_policy.rb', line 22

def initialize(user, messageboard)
  @user = user
  @messageboard = messageboard
end

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/policies/thredded/messageboard_policy.rb', line 27

def create?
  @user.thredded_admin?
end

#moderate?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/policies/thredded/messageboard_policy.rb', line 45

def moderate?
  @user.thredded_admin? || @user.thredded_can_moderate_messageboards.include?(@messageboard)
end

#post?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
# File 'app/policies/thredded/messageboard_policy.rb', line 39

def post?
  @user.thredded_admin? ||
    (!@messageboard.locked? || moderate?) &&
      @user.thredded_can_write_messageboards.include?(@messageboard)
end

#read?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/policies/thredded/messageboard_policy.rb', line 31

def read?
  @user.thredded_admin? || @user.thredded_can_read_messageboards.include?(@messageboard)
end

#update?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/policies/thredded/messageboard_policy.rb', line 35

def update?
  @user.thredded_admin?
end