Class: Gitlab::SnippetSearchResults

Inherits:
SearchResults show all
Includes:
SnippetsHelper
Defined in:
lib/gitlab/snippet_search_results.rb

Instance Attribute Summary collapse

Attributes inherited from SearchResults

#current_user, #limit_projects, #query

Instance Method Summary collapse

Methods included from SnippetsHelper

#bounded_line_numbers, #chunk_snippet, #matching_lines, #reliable_snippet_path

Methods inherited from SearchResults

#empty?, #issues_count, #merge_requests_count, #milestones_count, #projects_count

Constructor Details

#initialize(limit_snippets, query) ⇒ SnippetSearchResults

Returns a new instance of SnippetSearchResults


7
8
9
10
# File 'lib/gitlab/snippet_search_results.rb', line 7

def initialize(limit_snippets, query)
  @limit_snippets = limit_snippets
  @query = query
end

Instance Attribute Details

#limit_snippetsObject (readonly)

Returns the value of attribute limit_snippets


5
6
7
# File 'lib/gitlab/snippet_search_results.rb', line 5

def limit_snippets
  @limit_snippets
end

Instance Method Details

#objects(scope, page = nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/snippet_search_results.rb', line 12

def objects(scope, page = nil)
  case scope
  when 'snippet_titles'
    snippet_titles.page(page).per(per_page)
  when 'snippet_blobs'
    snippet_blobs.page(page).per(per_page)
  else
    super
  end
end

#snippet_blobs_countObject


31
32
33
# File 'lib/gitlab/snippet_search_results.rb', line 31

def snippet_blobs_count
  @snippet_blobs_count ||= snippet_blobs.count
end

#snippet_titles_countObject


27
28
29
# File 'lib/gitlab/snippet_search_results.rb', line 27

def snippet_titles_count
  @snippet_titles_count ||= snippet_titles.count
end

#total_countObject


23
24
25
# File 'lib/gitlab/snippet_search_results.rb', line 23

def total_count
  @total_count ||= snippet_titles_count + snippet_blobs_count
end