Class: OpenapiParameters::Cookie
- Inherits:
-
Object
- Object
- OpenapiParameters::Cookie
- Defined in:
- lib/openapi_parameters/cookie.rb
Overview
Cookie parses OpenAPI cookie parameters from a cookie string.
Instance Method Summary collapse
-
#initialize(parameters, convert: true) ⇒ Cookie
constructor
A new instance of Cookie.
- #unpack(cookie_string) ⇒ Object
Constructor Details
#initialize(parameters, convert: true) ⇒ Cookie
Returns a new instance of Cookie.
8 9 10 11 |
# File 'lib/openapi_parameters/cookie.rb', line 8 def initialize(parameters, convert: true) @parameters = parameters.map { Parameter.new(_1) } @convert = convert end |
Instance Method Details
#unpack(cookie_string) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/openapi_parameters/cookie.rb', line 14 def unpack() = Rack::Utils.() parameters.each_with_object({}) do |parameter, result| next unless .key?(parameter.name) result[parameter.name] = catch :skip do value = Unpacker.unpack_value(parameter, [parameter.name]) @convert ? parameter.convert(value) : value end end end |