Class: Flame::Dispatcher::Cookies

Inherits:
Object
  • Object
show all
Defined in:
lib/flame/dispatcher.rb

Overview

Helper class for cookies

Instance Method Summary collapse

Constructor Details

#initialize(request_cookies, response) ⇒ Cookies

Returns a new instance of Cookies.



132
133
134
135
# File 'lib/flame/dispatcher.rb', line 132

def initialize(request_cookies, response)
	@request_cookies = request_cookies
	@response = response
end

Instance Method Details

#[](key) ⇒ Object



137
138
139
# File 'lib/flame/dispatcher.rb', line 137

def [](key)
	@request_cookies[key.to_s]
end

#[]=(key, new_value) ⇒ Object



141
142
143
144
# File 'lib/flame/dispatcher.rb', line 141

def []=(key, new_value)
	return @response.delete_cookie(key.to_s, path: '/') if new_value.nil?
	@response.set_cookie(key.to_s, value: new_value, path: '/')
end