Module: Gitlab::SearchContext::ControllerConcern

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
lib/gitlab/search_context.rb

Instance Method Summary collapse

Instance Method Details

#search_contextObject

rubocop:disable Gitlab/ModuleWithInstanceVariables

Introspect the current controller's assignments and and builds the proper SearchContext object for it.


148
149
150
151
152
153
154
155
156
157
158
# File 'lib/gitlab/search_context.rb', line 148

def search_context
  builder = Builder.new(view_context)

  builder.with_snippet(@snippet) if @snippet.present?
  @snippets.each(&builder.method(:with_snippet)) if @snippets.present?
  builder.with_project(@project) if @project.present? && @project.persisted?
  builder.with_group(@group) if @group.present? && @group.persisted?
  builder.with_ref(@ref) if @ref.present?

  builder.build!
end