Class: LittleWeasel::Services::DictionaryFileLoaderService
- Inherits:
-
Object
- Object
- LittleWeasel::Services::DictionaryFileLoaderService
- Includes:
- Modules::Configurable, Modules::DictionaryCacheServicable, Modules::DictionaryFileLoader, Modules::DictionaryKeyable
- Defined in:
- lib/LittleWeasel/services/dictionary_file_loader_service.rb
Overview
This class provides a service for loading dictionaries from disk and returning a Hash of dictionary words that can be used to instantiate a Dictionary object or otherwise.
Instance Attribute Summary
Attributes included from Modules::DictionaryKeyable
Attributes included from Modules::DictionaryCacheServicable
#dictionary_cache, #dictionary_key
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(dictionary_key:, dictionary_cache:) ⇒ DictionaryFileLoaderService
constructor
A new instance of DictionaryFileLoaderService.
Methods included from Modules::DictionaryKeyValidatable
validate, #validate_dictionary_key
Methods included from Modules::DictionaryFileLoader
Methods included from Modules::DictionaryCacheServicable
Methods included from Modules::DictionaryCacheValidatable
validate, #validate_dictionary_cache
Methods included from Modules::Configurable
Constructor Details
#initialize(dictionary_key:, dictionary_cache:) ⇒ DictionaryFileLoaderService
Returns a new instance of DictionaryFileLoaderService.
19 20 21 22 23 24 25 |
# File 'lib/LittleWeasel/services/dictionary_file_loader_service.rb', line 19 def initialize(dictionary_key:, dictionary_cache:) validate_dictionary_key dictionary_key: dictionary_key self.dictionary_key = dictionary_key validate_dictionary_cache dictionary_cache: dictionary_cache self.dictionary_cache = dictionary_cache end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/LittleWeasel/services/dictionary_file_loader_service.rb', line 27 def execute if dictionary_cache_service.dictionary_exists? raise ArgumentError, "The dictionary associated with key '#{key}' already exists." end load dictionary_cache_service.dictionary_file! end |