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:



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

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

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


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

def create?
  @user.thredded_admin?
end

#destroy?Boolean

Returns:

  • (Boolean)


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

def destroy?
  @user.thredded_admin?
end

#moderate?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/policies/thredded/messageboard_policy.rb', line 54

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

#post?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'app/policies/thredded/messageboard_policy.rb', line 48

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

#read?Boolean

Returns:

  • (Boolean)


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

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

#update?Boolean

Returns:

  • (Boolean)


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

def update?
  @user.thredded_admin?
end