Class: Thredded::PrivatePostPolicy

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

Defined Under Namespace

Classes: Scope

Instance Method Summary collapse

Constructor Details

#initialize(user, post) ⇒ PrivatePostPolicy


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

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

Instance Method Details

#anonymous?Boolean


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

def anonymous?
  @user.thredded_anonymous?
end

#create?Boolean


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

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

#destroy?Boolean


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

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

#read?Boolean


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

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

#update?Boolean


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

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