Class: TrailGuide::Adapters::Participants::Cookie::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/trail_guide/adapters/participants/cookie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, config) ⇒ Adapter

Returns a new instance of Adapter.



36
37
38
39
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 36

def initialize(context, config)
  @context = context
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



34
35
36
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 34

def config
  @config
end

#contextObject (readonly)

Returns the value of attribute context.



34
35
36
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 34

def context
  @context
end

Instance Method Details

#[](key) ⇒ Object



41
42
43
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 41

def [](key)
  cookie[key.to_s]
end

#[]=(key, value) ⇒ Object



45
46
47
48
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 45

def []=(key, value)
  cookie.merge!({key.to_s => value})
  write_cookie
end

#delete(key) ⇒ Object



50
51
52
53
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 50

def delete(key)
  cookie.tap { |h| h.delete(key.to_s) }
  write_cookie
end

#destroy!Object



55
56
57
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 55

def destroy!
  cookies.delete(config.cookie.to_s)
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 63

def key?(key)
  cookie.key?(key)
end

#keysObject



59
60
61
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 59

def keys
  cookie.keys
end

#to_hObject



67
68
69
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 67

def to_h
  cookie.to_h
end