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.



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

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.



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

def allowed_values
  @allowed_values
end

#param_contentsObject (readonly)

Returns the value of attribute param_contents.



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

def param_contents
  @param_contents
end

#param_nameObject (readonly)

Returns the value of attribute param_name.



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

def param_name
  @param_name
end

Instance Method Details

#build_paramObject



17
18
19
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 17

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

#validate_allowed_values!Object (private)



23
24
25
# File 'lib/gitlab/triage/api_query_builders/base_query_param_builder.rb', line 23

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