Class: Split::Persistence::CookieAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/split/persistence/cookie_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ CookieAdapter

Returns a new instance of CookieAdapter.


8
9
10
11
# File 'lib/split/persistence/cookie_adapter.rb', line 8

def initialize(context)
  @cookies = context.send(:cookies)
  @expires = Time.now + cookie_length_config
end

Instance Method Details

#[](key) ⇒ Object


13
14
15
# File 'lib/split/persistence/cookie_adapter.rb', line 13

def [](key)
  hash[key]
end

#[]=(key, value) ⇒ Object


17
18
19
# File 'lib/split/persistence/cookie_adapter.rb', line 17

def []=(key, value)
  set_cookie(hash.merge(key => value))
end

#delete(key) ⇒ Object


21
22
23
# File 'lib/split/persistence/cookie_adapter.rb', line 21

def delete(key)
  set_cookie(hash.tap { |h| h.delete(key) })
end

#keysObject


25
26
27
# File 'lib/split/persistence/cookie_adapter.rb', line 25

def keys
  hash.keys
end