Class: QAT::Core
- Inherits:
-
Object
- Object
- QAT::Core
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/qat/core.rb,
lib/qat/core/version.rb
Overview
Namespace for QAT Core implementation
Constant Summary collapse
- VERSION =
Represents QAT’s Core version
'9.0.0'
Instance Method Summary collapse
-
#initialize ⇒ Core
constructor
A new instance of Core.
-
#make_permanent(key) ⇒ Object
Makes a key permanent in the cache, so that it won’t deleted when #reset! is called.
-
#reset! ⇒ Object
Deletes all keys not maked as permanent from the cache.
-
#store_permanently(key, value) ⇒ Object
Stores value to the given key and marks key as permanent, so that it won’t deleted when #reset! is called.
Constructor Details
#initialize ⇒ Core
Returns a new instance of Core.
19 20 21 22 |
# File 'lib/qat/core.rb', line 19 def initialize @storage = {} @exceptions = [] end |
Instance Method Details
#make_permanent(key) ⇒ Object
Makes a key permanent in the cache, so that it won’t deleted when #reset! is called.
27 28 29 |
# File 'lib/qat/core.rb', line 27 def make_permanent key @exceptions << key unless @exceptions.include? key end |
#reset! ⇒ Object
Deletes all keys not maked as permanent from the cache.
43 44 45 |
# File 'lib/qat/core.rb', line 43 def reset! @storage.select! { |key, _| @exceptions.include?(key) } end |
#store_permanently(key, value) ⇒ Object
Stores value to the given key and marks key as permanent, so that it won’t deleted when #reset! is called.
36 37 38 39 |
# File 'lib/qat/core.rb', line 36 def store_permanently key, value make_permanent key store key, value end |