Class: Loco::WsConnectionStorage
- Inherits:
-
Object
- Object
- Loco::WsConnectionStorage
- Includes:
- Singleton
- Defined in:
- lib/loco/ws_connection_storage.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Class Method Summary collapse
Instance Method Summary collapse
- #del(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ WsConnectionStorage
constructor
A new instance of WsConnectionStorage.
- #set(key, val) ⇒ Object
Constructor Details
#initialize ⇒ WsConnectionStorage
Returns a new instance of WsConnectionStorage.
15 16 17 |
# File 'lib/loco/ws_connection_storage.rb', line 15 def initialize @storage = Config.redis_instance || {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
7 8 9 |
# File 'lib/loco/ws_connection_storage.rb', line 7 def storage @storage end |
Class Method Details
.current ⇒ Object
10 11 12 |
# File 'lib/loco/ws_connection_storage.rb', line 10 def current instance end |
Instance Method Details
#del(key) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/loco/ws_connection_storage.rb', line 37 def del key case @storage when Hash storage.delete proper_key(key) else storage.del proper_key(key) end end |
#get(key) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/loco/ws_connection_storage.rb', line 19 def get key case @storage when Hash storage[proper_key(key)] else storage.get proper_key(key) end end |
#set(key, val) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/loco/ws_connection_storage.rb', line 28 def set key, val case @storage when Hash storage[proper_key(key)] = val else storage.set proper_key(key), val end end |