Class: OpenapiParameters::Header
- Inherits:
-
Object
- Object
- OpenapiParameters::Header
- Defined in:
- lib/openapi_parameters/header.rb
Overview
Header parses OpenAPI parameters from the request headers.
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(parameters, convert: true) ⇒ Header
constructor
A new instance of Header.
- #unpack(headers) ⇒ Object
- #unpack_env(env) ⇒ Object
Constructor Details
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
29 30 31 |
# File 'lib/openapi_parameters/header.rb', line 29 def parameters @parameters end |
Instance Method Details
#unpack(headers) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/openapi_parameters/header.rb', line 14 def unpack(headers) parameters.each_with_object({}) do |parameter, result| next unless headers.key?(parameter.name) result[parameter.name] = catch :skip do value = Unpacker.unpack_value(parameter, headers[parameter.name]) @convert ? Converter.convert(value, parameter.schema) : value end end end |
#unpack_env(env) ⇒ Object
25 26 27 |
# File 'lib/openapi_parameters/header.rb', line 25 def unpack_env(env) unpack(HeadersHash.new(env)) end |