Class: TrailGuide::Adapters::Participants::Cookie::Adapter
- Inherits:
-
Base::Adapter
- Object
- Base::Adapter
- TrailGuide::Adapters::Participants::Cookie::Adapter
- Defined in:
- lib/trail_guide/adapters/participants/cookie.rb
Instance Attribute Summary
Attributes inherited from Base::Adapter
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
- #destroy! ⇒ Object
-
#initialize(context, config) ⇒ Adapter
constructor
A new instance of Adapter.
- #key?(key) ⇒ Boolean
- #keys ⇒ Object
- #to_h ⇒ Object
Methods inherited from Base::Adapter
Constructor Details
#initialize(context, config) ⇒ Adapter
Returns a new instance of Adapter.
18 19 20 21 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 18 def initialize(context, config) raise UnsupportedContextError, "Your current context (#{context}) does not support cookies" unless context.respond_to?(:cookies, true) super end |
Instance Method Details
#[](key) ⇒ Object
23 24 25 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 23 def [](key) [key.to_s] end |
#[]=(key, value) ⇒ Object
27 28 29 30 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 27 def []=(key, value) .merge!({key.to_s => value}) end |
#delete(key) ⇒ Object
32 33 34 35 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 32 def delete(key) .tap { |h| h.delete(key.to_s) } end |
#destroy! ⇒ Object
37 38 39 40 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 37 def destroy! = nil .delete(config..to_s) end |
#key?(key) ⇒ Boolean
46 47 48 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 46 def key?(key) .key?(key) end |
#keys ⇒ Object
42 43 44 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 42 def keys .keys end |
#to_h ⇒ Object
50 51 52 |
# File 'lib/trail_guide/adapters/participants/cookie.rb', line 50 def to_h .to_h end |