Class: Search::SnippetService

Inherits:
Object
  • Object
show all
Defined in:
app/services/search/snippet_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, params) ⇒ SnippetService

Returns a new instance of SnippetService


5
6
7
# File 'app/services/search/snippet_service.rb', line 5

def initialize(user, params)
  @current_user, @params = user, params.dup
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


3
4
5
# File 'app/services/search/snippet_service.rb', line 3

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params


3
4
5
# File 'app/services/search/snippet_service.rb', line 3

def params
  @params
end

Instance Method Details

#executeObject


9
10
11
12
13
# File 'app/services/search/snippet_service.rb', line 9

def execute
  snippets = Snippet.accessible_to(current_user)

  Gitlab::SnippetSearchResults.new(snippets, params[:search])
end