Class: QAT::Core

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/qat/core.rb,
lib/qat/core/version.rb

Overview

Namespace for QAT Core implementation

Since:

  • 0.1.0

Constant Summary collapse

VERSION =

Represents QAT’s Core version

Since:

  • 0.1.0

'9.0.0'

Instance Method Summary collapse

Constructor Details

#initializeCore

Returns a new instance of Core.

Since:

  • 0.1.0



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.

Parameters:

  • key (Object)

    Key to make permanent

See Also:

Since:

  • 0.1.0



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.

Since:

  • 0.1.0



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.

Parameters:

  • key (Object)

    Key to make permanent

  • value (Object)

    Value to store in cache

See Also:

Since:

  • 0.1.0



36
37
38
39
# File 'lib/qat/core.rb', line 36

def store_permanently key, value
  make_permanent key
  store key, value
end