Class: Projects::SnippetsController

Inherits:
Projects::Snippets::ApplicationController
  • Object
show all
Includes:
SnippetsActions, SpammableActions, ToggleAwardEmoji
Defined in:
app/controllers/projects/snippets_controller.rb

Instance Method Summary collapse

Methods included from SpammableActions

#mark_as_spam

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from ToggleAwardEmoji

#toggle_award_emoji

Methods included from SnippetsActions

#destroy, #edit, #js_request?, #raw, #show, #update

Methods included from SnippetsSort

#sort_param

Methods included from Snippets::SendBlob

#send_snippet_blob

Methods included from SendsBlob

#send_blob

Methods included from Gitlab::NoteableMetadata

#noteable_meta_data

Methods included from RendersBlob

#blob_json, #conditionally_expand_blob, #conditionally_expand_blobs, #render_blob_json

Methods included from RendersNotes

#prepare_notes_for_rendering

Instance Method Details

#createObject


40
41
42
43
44
45
46
# File 'app/controllers/projects/snippets_controller.rb', line 40

def create
  create_params = snippet_params.merge(spammable_params)
  service_response = ::Snippets::CreateService.new(project, current_user, create_params).execute
  @snippet = service_response.payload[:snippet]

  handle_repository_error(:new)
end

#indexObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/projects/snippets_controller.rb', line 21

def index
  @snippet_counts = ::Snippets::CountService
    .new(current_user, project: @project)
    .execute

  @snippets = SnippetsFinder.new(current_user, project: @project, scope: params[:scope], sort: sort_param)
    .execute
    .page(params[:page])
    .inc_author

  return if redirect_out_of_range(@snippets)

  @noteable_meta_data = (@snippets, 'Snippet')
end

#newObject


36
37
38
# File 'app/controllers/projects/snippets_controller.rb', line 36

def new
  @snippet = @noteable = @project.snippets.build
end