Sha256: a7110e6291bdb619b011a8c19b8bd1fc2989cd243e9fdc109acd5becfd60077b
Contents?: true
Size: 874 Bytes
Versions: 10
Compression:
Stored size: 874 Bytes
Contents
module Grape class Cookies def initialize @cookies = {} @send_cookies = {} end def read(request) request.cookies.each do |name, value| @cookies[name.to_s] = value end end def write(header) @cookies.select { |key, value| @send_cookies[key] == true }.each { |name, value| cookie_value = value.is_a?(Hash) ? value : { :value => value } Rack::Utils.set_cookie_header! header, name, cookie_value } end def [](name) @cookies[name.to_s] end def []=(name, value) @cookies[name.to_s] = value @send_cookies[name.to_s] = true end def each(&block) @cookies.each(&block) end def delete(name, opts = {}) options = opts.merge({ :value => 'deleted', :expires => Time.at(0) }) self.[]=(name, options) end end end
Version data entries
10 entries across 10 versions & 1 rubygems