Class: Gitlab::Triage::GraphqlQueries::QueryParamBuilders::BaseParamBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb

Direct Known Subclasses

DateParamBuilder, LabelsParamBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param_name, param_contents, with_quotes: true, negated: false) ⇒ BaseParamBuilder

Returns a new instance of BaseParamBuilder.



10
11
12
13
14
15
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 10

def initialize(param_name, param_contents, with_quotes: true, negated: false)
  @param_name = param_name
  @param_contents = param_contents.to_s.strip
  @with_quotes = with_quotes
  @negated = negated
end

Instance Attribute Details

#negatedObject (readonly)

Returns the value of attribute negated.



8
9
10
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 8

def negated
  @negated
end

#param_contentsObject (readonly)

Returns the value of attribute param_contents.



8
9
10
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 8

def param_contents
  @param_contents
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



8
9
10
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 8

def param_name
  @param_name
end

#with_quotesObject (readonly)

Returns the value of attribute with_quotes.



8
9
10
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 8

def with_quotes
  @with_quotes
end

Instance Method Details

#build_paramObject



17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/triage/graphql_queries/query_param_builders/base_param_builder.rb', line 17

def build_param
  contents = with_quotes ? Utils.graphql_quote(param_contents) : param_contents

  if negated
    ", not: { #{param_name}: #{contents} }"
  else
    ", #{param_name}: #{contents}"
  end
end