Class: Thredded::PrivateTopicPolicy

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

Instance Method Summary collapse

Constructor Details

#initialize(user, private_topic) ⇒ PrivateTopicPolicy

Returns a new instance of PrivateTopicPolicy.

Parameters:


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

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

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)

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

def create?
  !@user.thredded_anonymous? && !@user.thredded_user_detail.blocked?
end

#read?Boolean

Returns:

  • (Boolean)

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

def read?
  @private_topic.users.include?(@user)
end

#update?Boolean

Returns:

  • (Boolean)

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

def update?
  !@user.thredded_anonymous? && @user.id == @private_topic.user_id
end