Class: Gitlab::Triage::APIQueryBuilders::BaseQueryParamBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/triage/api_query_builders/base_query_param_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param_name, param_contents, allowed_values: nil) ⇒ BaseQueryParamBuilder

Returns a new instance of BaseQueryParamBuilder.



7
8
9
10
11
12
13
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 7

def initialize(param_name, param_contents, allowed_values: nil)
  @param_name = param_name
  @param_contents = param_contents
  @allowed_values = allowed_values

  validate_allowed_values! if allowed_values
end

Instance Attribute Details

#allowed_valuesObject (readonly)

Returns the value of attribute allowed_values.



5
6
7
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 5

def allowed_values
  @allowed_values
end

#param_contentsObject (readonly)

Returns the value of attribute param_contents.



5
6
7
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 5

def param_contents
  @param_contents
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



5
6
7
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 5

def param_name
  @param_name
end

Instance Method Details

#build_paramObject



15
16
17
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 15

def build_param
  "&#{param_name}=#{param_content.strip}"
end

#validate_allowed_values!Object (private)



21
22
23
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 21

def validate_allowed_values!
  ParamsValidator.new([{ name: param_name, type: String, values: allowed_values }], { param_name => param_contents }).validate!
end