Class: OpenapiParameters::Query
- Inherits:
-
Object
- Object
- OpenapiParameters::Query
- Defined in:
- lib/openapi_parameters/query.rb
Overview
Query parses query parameters from a http query strings.
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(parameters, convert: true) ⇒ Query
constructor
A new instance of Query.
-
#unpack(query_string) ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
32 33 34 |
# File 'lib/openapi_parameters/query.rb', line 32 def parameters @parameters end |
Instance Method Details
#unpack(query_string) ⇒ Object
rubocop:disable Metrics/AbcSize
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/openapi_parameters/query.rb', line 15 def unpack(query_string) # rubocop:disable Metrics/AbcSize parsed_query = Rack::Utils.parse_query(query_string) parameters.each_with_object({}) do |parameter, result| if parameter.deep_object? parsed_nested_query = Rack::Utils.parse_nested_query(query_string) next unless parsed_nested_query.key?(parameter.name) result[parameter.name] = convert(parsed_nested_query[parameter.name], parameter) else next unless parsed_query.key?(parameter.name) value = Unpacker.unpack_value(parameter, parsed_query[parameter.name]) result[parameter.name] = convert(value, parameter) end end end |