Module: Vedeu::Output::CompressorCache Private

Extended by:
CompressorCache, Repositories::Storage
Included in:
CompressorCache
Defined in:
lib/vedeu/output/compressor_cache.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Store a copy of the data last processed by Compressor. Both the original content and the compressed versions are kept (unless modified) to speed up the rendering of the display.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.in_memoryHash<Symbol => Array<void>> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Array<void>>)


37
38
39
40
41
42
# File 'lib/vedeu/output/compressor_cache.rb', line 37

def in_memory
  {
    compressed: '',
    original:   [],
  }
end

.invalid_key?(key) ⇒ Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)

Returns:



46
47
48
# File 'lib/vedeu/output/compressor_cache.rb', line 46

def invalid_key?(key)
  key.nil? || !in_memory.keys.include?(key)
end

.invalid_value?(value) ⇒ Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Array|NilClass)

Returns:



52
53
54
# File 'lib/vedeu/output/compressor_cache.rb', line 52

def invalid_value?(value)
  value.nil? || value.empty?
end

.read(key) ⇒ Array<void>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)

Returns:

  • (Array<void>)


21
22
23
# File 'lib/vedeu/output/compressor_cache.rb', line 21

def read(key)
  storage.fetch(key, [])
end

.reset!void Also known as: reset Originally defined in module Repositories::Storage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Remove all currently stored data for this repository.

.storagevoid Also known as: all Originally defined in module Repositories::Storage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Return whole repository; provides raw access to the storage for this repository.

.write(key, value) ⇒ Hash<Symbol => Array<void>>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)
  • value (Array|NilClass)

Returns:

  • (Hash<Symbol => Array<void>>)


28
29
30
31
32
# File 'lib/vedeu/output/compressor_cache.rb', line 28

def write(key, value)
  return storage if invalid_key?(key) || invalid_value?(value)

  storage.merge!(key => value)
end

Instance Method Details

#in_memoryHash<Symbol => Array<void>> (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash<Symbol => Array<void>>)


37
38
39
40
41
42
# File 'lib/vedeu/output/compressor_cache.rb', line 37

def in_memory
  {
    compressed: '',
    original:   [],
  }
end

#invalid_key?(key) ⇒ Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)

Returns:



46
47
48
# File 'lib/vedeu/output/compressor_cache.rb', line 46

def invalid_key?(key)
  key.nil? || !in_memory.keys.include?(key)
end

#invalid_value?(value) ⇒ Boolean (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Array|NilClass)

Returns:



52
53
54
# File 'lib/vedeu/output/compressor_cache.rb', line 52

def invalid_value?(value)
  value.nil? || value.empty?
end

#read(key) ⇒ Array<void>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)

Returns:

  • (Array<void>)


21
22
23
# File 'lib/vedeu/output/compressor_cache.rb', line 21

def read(key)
  storage.fetch(key, [])
end

#write(key, value) ⇒ Hash<Symbol => Array<void>>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (NilClass|Symbol)
  • value (Array|NilClass)

Returns:

  • (Hash<Symbol => Array<void>>)


28
29
30
31
32
# File 'lib/vedeu/output/compressor_cache.rb', line 28

def write(key, value)
  return storage if invalid_key?(key) || invalid_value?(value)

  storage.merge!(key => value)
end