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

ArrayParamBuilder, DateParamBuilder

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.



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

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.



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

def negated
  @negated
end

#param_contentsObject (readonly)

Returns the value of attribute param_contents.



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

def param_contents
  @param_contents
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



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

def param_name
  @param_name
end

#with_quotesObject (readonly)

Returns the value of attribute with_quotes.



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

def with_quotes
  @with_quotes
end

Instance Method Details

#build_paramObject



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

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