Class: Thredded::PrivatePostPolicy

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

Instance Method Summary collapse

Constructor Details

#initialize(user, post) ⇒ PrivatePostPolicy

Returns a new instance of PrivatePostPolicy.

Parameters:



7
8
9
10
# File 'app/policies/thredded/private_post_policy.rb', line 7

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

Instance Method Details

#anonymous?Boolean

Returns:

  • (Boolean)


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

def anonymous?
  @user.thredded_anonymous?
end

#create?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/policies/thredded/private_post_policy.rb', line 12

def create?
  @user.thredded_admin? || @post.postable.users.include?(@user) && !@user.thredded_user_detail.blocked?
end

#destroy?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/policies/thredded/private_post_policy.rb', line 24

def destroy?
  !@post.first_post_in_topic? && update?
end

#read?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/policies/thredded/private_post_policy.rb', line 16

def read?
  Thredded::PrivateTopicPolicy.new(@user, @post.postable).read?
end

#update?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/policies/thredded/private_post_policy.rb', line 20

def update?
  @user.thredded_admin? || own_post?
end