Sha256: 04ed2788f401b5d4b711378db3dadc906e1fccc5fbde0fc957f3188d36286395

Contents?: true

Size: 595 Bytes

Versions: 5

Compression:

Stored size: 595 Bytes

Contents

module Rack
  class Response
    def cookies
      cookie_key_value_array.each_with_object({}) do |cookie_data_hash, cookies|
        name, value = *cookie_data_hash.delete_at(0)
        data = cookie_data(cookie_data_hash)
        cookies[name] = { value: value }.merge(data)
      end
    end

    def cookie_data(cookie_data_hash)
      cookie_data_hash.collect { |key, assigned_data| [key.to_sym, assigned_data] }.to_h
    end

    def cookie_key_value_array
      value = header['Set-Cookie'] || ''
      value.lines.collect { |line| line.scan(%r{([\.\w]+)=([\.\w/]+)}) }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sitehub-0.4.10 spec/support/patch/rack/response.rb
sitehub-0.5.0.alpha3 spec/support/patch/rack/response.rb
sitehub-0.5.0.alpha2 spec/support/patch/rack/response.rb
sitehub-0.4.9 spec/support/patch/rack/response.rb
sitehub-0.4.8 spec/support/patch/rack/response.rb