Class: Userbin::CookieStore::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/userbin/support/cookie_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(cookies) ⇒ Rack

Returns a new instance of Rack


26
27
28
# File 'lib/userbin/support/cookie_store.rb', line 26

def initialize(cookies)
  @cookies = cookies
end

Instance Method Details

#[](key) ⇒ Object


30
31
32
# File 'lib/userbin/support/cookie_store.rb', line 30

def [](key)
  @cookies[key]
end

#[]=(key, value) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/userbin/support/cookie_store.rb', line 34

def []=(key, value)
  if value
    @cookies[key] = {
      value: value,
      expires: Time.now + (20 * 365 * 24 * 60 * 60),
      path: '/'
    }
  else
    @cookies.delete(key)
  end
end