Class: Thredded::PrivateTopicPolicy
- Inherits:
-
Object
- Object
- Thredded::PrivateTopicPolicy
- Defined in:
- app/policies/thredded/private_topic_policy.rb
Instance Method Summary collapse
- #create? ⇒ Boolean
-
#initialize(user, private_topic) ⇒ PrivateTopicPolicy
constructor
A new instance of PrivateTopicPolicy.
- #read? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, private_topic) ⇒ PrivateTopicPolicy
Returns a new instance of PrivateTopicPolicy.
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
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
16 17 18 |
# File 'app/policies/thredded/private_topic_policy.rb', line 16 def read? @private_topic.users.include?(@user) end |
#update? ⇒ 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 |