BigW Consortium Gitlab

personal_snippet_policy.rb 374 Bytes
Newer Older
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