2016-08-16 19:46:35 -04:00
|
|
|
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
|
2016-11-26 10:37:26 -05:00
|
|
|
can! :destroy_personal_snippet
|
2016-08-16 19:46:35 -04:00
|
|
|
can! :admin_personal_snippet
|
|
|
|
end
|
|
|
|
|
2016-11-26 10:37:26 -05:00
|
|
|
unless @user.external?
|
|
|
|
can! :create_personal_snippet
|
|
|
|
end
|
|
|
|
|
2016-08-16 19:46:35 -04:00
|
|
|
if @subject.internal? && !@user.external?
|
|
|
|
can! :read_personal_snippet
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|