Class: Thredded::PrivatePostPolicy
- Inherits:
-
Object
- Object
- Thredded::PrivatePostPolicy
- Defined in:
- app/policies/thredded/private_post_policy.rb
Instance Method Summary collapse
- #anonymous? ⇒ Boolean
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
-
#initialize(user, post) ⇒ PrivatePostPolicy
constructor
A new instance of PrivatePostPolicy.
- #read? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, post) ⇒ PrivatePostPolicy
Returns a new instance of PrivatePostPolicy.
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
28 29 30 |
# File 'app/policies/thredded/private_post_policy.rb', line 28 def anonymous? @user.thredded_anonymous? end |
#create? ⇒ 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
24 25 26 |
# File 'app/policies/thredded/private_post_policy.rb', line 24 def destroy? !@post.first_post_in_topic? && update? end |
#read? ⇒ 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
20 21 22 |
# File 'app/policies/thredded/private_post_policy.rb', line 20 def update? @user.thredded_admin? || own_post? end |