Sha256: 97b25bada4be865c42acc8a416387ff6f61c550248ebecea38cc8b2eb11798e6

Contents?: true

Size: 569 Bytes

Versions: 2

Compression:

Stored size: 569 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
      header['Set-Cookie'].lines.collect { |line| line.scan(%r{([\.\w]+)=([\.\w/]+)}) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitehub-0.4.7 spec/support/patch/rack/response.rb
sitehub-0.4.6 spec/support/patch/rack/response.rb