gitlab-org--gitlab-foss/app/services/create_snippet_service.rb
2016-07-06 20:58:43 +03:00

19 lines
439 B
Ruby

class CreateSnippetService < BaseService
def execute
snippet = if project
project.snippets.build(params)
else
PersonalSnippet.new(params)
end
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
deny_visibility_level(snippet)
return snippet
end
snippet.author = current_user
snippet.save
snippet
end
end