Class: Thredded::MessageboardPolicy
- Inherits:
-
Object
- Object
- Thredded::MessageboardPolicy
- Defined in:
- app/policies/thredded/messageboard_policy.rb
Defined Under Namespace
Classes: Scope
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
-
#initialize(user, messageboard) ⇒ MessageboardPolicy
constructor
A new instance of MessageboardPolicy.
- #moderate? ⇒ Boolean
- #post? ⇒ Boolean
- #read? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(user, messageboard) ⇒ MessageboardPolicy
Returns a new instance of MessageboardPolicy.
27 28 29 30 |
# File 'app/policies/thredded/messageboard_policy.rb', line 27 def initialize(user, ) @user = user @messageboard = end |
Instance Method Details
#create? ⇒ Boolean
32 33 34 |
# File 'app/policies/thredded/messageboard_policy.rb', line 32 def create? @user.thredded_admin? end |
#destroy? ⇒ Boolean
44 45 46 |
# File 'app/policies/thredded/messageboard_policy.rb', line 44 def destroy? @user.thredded_admin? end |
#moderate? ⇒ Boolean
54 55 56 |
# File 'app/policies/thredded/messageboard_policy.rb', line 54 def moderate? @user.thredded_admin? || @user.(@messageboard) end |
#post? ⇒ Boolean
48 49 50 51 52 |
# File 'app/policies/thredded/messageboard_policy.rb', line 48 def post? @user.thredded_admin? || (!@messageboard.locked? || moderate?) && @user..include?(@messageboard) end |
#read? ⇒ Boolean
36 37 38 |
# File 'app/policies/thredded/messageboard_policy.rb', line 36 def read? @user.thredded_admin? || @user.(@messageboard) end |
#update? ⇒ Boolean
40 41 42 |
# File 'app/policies/thredded/messageboard_policy.rb', line 40 def update? @user.thredded_admin? end |