summaryrefslogtreecommitdiff
path: root/app/policies/personal_snippet_policy.rb
blob: 46c5aa1a5be4849b8498d856873707af84b6b8b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class PersonalSnippetPolicy < BasePolicy
  def rules
    can! :read_personal_snippet if @subject.public?
    return unless @user

    if @subject.author == @user
      can! :read_personal_snippet
      can! :update_personal_snippet
      can! :admin_personal_snippet
    end

    if @subject.internal? && !@user.external?
      can! :read_personal_snippet
    end
  end
end