Class: Proclaim::CommentPolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/proclaim/comment_policy.rb

Defined Under Namespace

Classes: Scope

Instance Attribute Summary

Attributes inherited from ApplicationPolicy

#record, #user

Instance Method Summary collapse

Methods inherited from ApplicationPolicy

#edit?, #index?, #initialize, #new?, #scope, #show?

Constructor Details

This class inherits a constructor from ApplicationPolicy

Instance Method Details

#create?Boolean



3
4
5
6
7
8
9
10
11
# File 'app/policies/proclaim/comment_policy.rb', line 3

def create?
  # Users can comment on whatever they want, but guests can only comment
  # on published posts
  if @user
    true
  else
    @record.post.published?
  end
end

#destroy?Boolean



17
18
19
# File 'app/policies/proclaim/comment_policy.rb', line 17

def destroy?
  not @user.nil?
end

#update?Boolean



13
14
15
# File 'app/policies/proclaim/comment_policy.rb', line 13

def update?
  not @user.nil?
end