Class: Mangadex::Storage::Memory
- Inherits:
- BasicObject
- Defined in:
- lib/mangadex/storage/memory.rb
Instance Method Summary collapse
- #clear(scope) ⇒ Object
- #get(scope, key) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #set(scope, key, value) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
4 5 6 |
# File 'lib/mangadex/storage/memory.rb', line 4 def initialize @storage = {} end |
Instance Method Details
#clear(scope) ⇒ Object
18 19 20 |
# File 'lib/mangadex/storage/memory.rb', line 18 def clear(scope) @storage.delete(scope) end |
#get(scope, key) ⇒ Object
8 9 10 |
# File 'lib/mangadex/storage/memory.rb', line 8 def get(scope, key) @storage.dig(scope.to_s, key.to_s) end |
#set(scope, key, value) ⇒ Object
12 13 14 15 16 |
# File 'lib/mangadex/storage/memory.rb', line 12 def set(scope, key, value) key = key.to_s @storage[scope] = {} unless @storage.has_key?(scope) @storage[scope][key] = value end |