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:



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

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

Instance Method Details

#create?Boolean

Returns:

  • (Boolean)


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

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

#read?Boolean

Returns:

  • (Boolean)


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

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

#update?Boolean

Returns:

  • (Boolean)


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

def update?
  @user.id == @private_topic.user_id
end