Class: Gitlab::SearchContext
- Inherits:
-
Object
- Object
- Gitlab::SearchContext
- Defined in:
- lib/gitlab/search_context.rb
Overview
Holds the contextual data used by navbar search component to determine the search scope, whether to search for code, or if a search should target snippets.
Use the SearchContext::Builder to create an instance of this class
Defined Under Namespace
Modules: ControllerConcern Classes: Builder
Instance Attribute Summary collapse
-
#group ⇒ Object
Returns the value of attribute group.
-
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
-
#project ⇒ Object
Returns the value of attribute project.
-
#project_metadata ⇒ Object
Returns the value of attribute project_metadata.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#search_url ⇒ Object
Returns the value of attribute search_url.
-
#snippets ⇒ Object
Returns the value of attribute snippets.
Instance Method Summary collapse
- #code_search? ⇒ Boolean
- #for_group? ⇒ Boolean
- #for_project? ⇒ Boolean
- #for_snippets? ⇒ Boolean
-
#initialize ⇒ SearchContext
constructor
A new instance of SearchContext.
Constructor Details
#initialize ⇒ SearchContext
Returns a new instance of SearchContext.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gitlab/search_context.rb', line 15 def initialize @ref = nil @project = nil @project_metadata = {} @group = nil @group_metadata = {} @snippets = [] @scope = nil @search_url = nil end |
Instance Attribute Details
#group ⇒ Object
Returns the value of attribute group.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def group @group end |
#group_metadata ⇒ Object
Returns the value of attribute group_metadata.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def @group_metadata end |
#project ⇒ Object
Returns the value of attribute project.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def project @project end |
#project_metadata ⇒ Object
Returns the value of attribute project_metadata.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def @project_metadata end |
#ref ⇒ Object
Returns the value of attribute ref.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def ref @ref end |
#scope ⇒ Object
Returns the value of attribute scope.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def scope @scope end |
#search_url ⇒ Object
Returns the value of attribute search_url.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def search_url @search_url end |
#snippets ⇒ Object
Returns the value of attribute snippets.
10 11 12 |
# File 'lib/gitlab/search_context.rb', line 10 def snippets @snippets end |
Instance Method Details
#code_search? ⇒ Boolean
38 39 40 |
# File 'lib/gitlab/search_context.rb', line 38 def code_search? project.present? && scope.nil? end |
#for_group? ⇒ Boolean
30 31 32 |
# File 'lib/gitlab/search_context.rb', line 30 def for_group? group.present? && group.persisted? end |
#for_project? ⇒ Boolean
26 27 28 |
# File 'lib/gitlab/search_context.rb', line 26 def for_project? project.present? && project.persisted? end |
#for_snippets? ⇒ Boolean
34 35 36 |
# File 'lib/gitlab/search_context.rb', line 34 def for_snippets? snippets.any? end |