Class: Gitlab::SearchContext::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/search_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ Builder

Returns a new instance of Builder.


43
44
45
46
# File 'lib/gitlab/search_context.rb', line 43

def initialize(view_context)
  @view_context = view_context
  @snippets = []
end

Instance Method Details

#build!Object


73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/gitlab/search_context.rb', line 73

def build!
  SearchContext.new.tap do |context|
    context.project = @project
    context.group = @group
    context.ref = @ref
    context.snippets = @snippets.dup
    context.scope = search_scope
    context.search_url = search_url
    context. = (@group)
    context. = (@project)
  end
end

#with_group(group) ⇒ Object


61
62
63
64
65
# File 'lib/gitlab/search_context.rb', line 61

def with_group(group)
  @group = group

  self
end

#with_project(project) ⇒ Object


54
55
56
57
58
59
# File 'lib/gitlab/search_context.rb', line 54

def with_project(project)
  @project = project
  with_group(project&.group)

  self
end

#with_ref(ref) ⇒ Object


67
68
69
70
71
# File 'lib/gitlab/search_context.rb', line 67

def with_ref(ref)
  @ref = ref

  self
end

#with_snippet(snippet) ⇒ Object


48
49
50
51
52
# File 'lib/gitlab/search_context.rb', line 48

def with_snippet(snippet)
  @snippets << snippet

  self
end