Class: Flame::Cookies

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

Overview

Helper class for cookies

Instance Method Summary collapse

Constructor Details

#initialize(request_cookies, response) ⇒ Cookies

Returns a new instance of Cookies.



4
5
6
7
# File 'lib/flame/cookies.rb', line 4

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

Instance Method Details

#[](key) ⇒ Object



9
10
11
# File 'lib/flame/cookies.rb', line 9

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

#[]=(key, new_value) ⇒ Object



13
14
15
16
# File 'lib/flame/cookies.rb', line 13

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