Class: Thredded::TopicPolicy
- Inherits:
-
Object
- Object
- Thredded::TopicPolicy
- Defined in:
- app/policies/thredded/topic_policy.rb
Defined Under Namespace
Classes: Scope
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
-
#initialize(user, topic) ⇒ TopicPolicy
constructor
A new instance of TopicPolicy.
- #moderate? ⇒ Boolean
- #read? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, topic) ⇒ TopicPolicy
Returns a new instance of TopicPolicy.
23 24 25 26 27 |
# File 'app/policies/thredded/topic_policy.rb', line 23 def initialize(user, topic) @user = user @topic = topic @messageboard_policy = Thredded::MessageboardPolicy.new(user, topic.) end |
Instance Method Details
#create? ⇒ Boolean
29 30 31 |
# File 'app/policies/thredded/topic_policy.rb', line 29 def create? @messageboard_policy.post? end |
#destroy? ⇒ Boolean
41 42 43 |
# File 'app/policies/thredded/topic_policy.rb', line 41 def destroy? @user.thredded_admin? end |
#moderate? ⇒ Boolean
45 46 47 |
# File 'app/policies/thredded/topic_policy.rb', line 45 def moderate? @messageboard_policy.moderate? end |
#read? ⇒ Boolean
33 34 35 |
# File 'app/policies/thredded/topic_policy.rb', line 33 def read? @messageboard_policy.read? && @topic.moderation_state_visible_to_user?(@user) end |
#update? ⇒ Boolean
37 38 39 |
# File 'app/policies/thredded/topic_policy.rb', line 37 def update? @user.thredded_admin? || @topic.user_id == @user.id || moderate? end |