Sha256: 17cc32f0995a39ba9087e54010145d99fb8c89495c22c1bf4100b8efa8055ef4

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module LittleWeasel
  module Modules
    # This module provides methods and constants used to define, initialize
    # and manipulate a dictionary cache Hash object.
    module DictionaryCacheKeys
      DICTIONARY_CACHE = 'dictionary_cache'
      DICTIONARY_REFERENCES = 'dictionary_references'
      DICTIONARY_ID = 'dictionary_id'
      DICTIONARIES = 'dictionaries'
      SOURCE = 'source'
      DICTIONARY_OBJECT = 'dictionary_object'

      module_function

      def initialize_dictionary_cache(dictionary_cache:)
        dictionary_cache.each_key { |key| dictionary_cache.delete(key) }
        dictionary_cache[DICTIONARY_CACHE] = initialized_dictionary_cache(include_root: false)
        dictionary_cache
      end

      def initialized_dictionary_cache(include_root: true)
        dictionary_cache = {
          DICTIONARY_REFERENCES => {},
          DICTIONARIES => {}
        }
        return { DICTIONARY_CACHE => dictionary_cache } if include_root

        dictionary_cache
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
LittleWeasel-5.0.13 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.12 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.11 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.10 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.9 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.8 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.7 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.6 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.5 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.4 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.3 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.2 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.1 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-5.0.0 lib/LittleWeasel/modules/dictionary_cache_keys.rb
LittleWeasel-4.0.0 lib/LittleWeasel/modules/dictionary_cache_keys.rb