class LittleWeasel::Services::DictionaryFileLoaderService
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.
Public Class Methods
new(dictionary_key:, dictionary_cache:)
click to toggle source
# 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
Public Instance Methods
execute()
click to toggle source
# 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