Module: LittleWeasel::Modules::DictionaryValidatable
- Included in:
- Services::DictionaryCacheService
- Defined in:
- lib/LittleWeasel/modules/dictionary_validatable.rb
Overview
This module provides validations related to dictionaries in the dictionary cache.
Class Method Summary collapse
- .validate_dictionary_does_not_exist(dictionary_cache_service:) ⇒ Object
- .validate_dictionary_reference_does_not_exist(dictionary_cache_service:) ⇒ Object
- .validate_dictionary_source_does_not_exist(dictionary_cache_service:) ⇒ Object
Instance Method Summary collapse
- #validate_dictionary_does_not_exist(dictionary_cache_service:) ⇒ Object private
- #validate_dictionary_reference_does_not_exist(dictionary_cache_service:) ⇒ Object private
- #validate_dictionary_source_does_not_exist(dictionary_cache_service:) ⇒ Object private
Class Method Details
.validate_dictionary_does_not_exist(dictionary_cache_service:) ⇒ Object
17 18 19 20 21 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 17 def validate_dictionary_does_not_exist(dictionary_cache_service:) if dictionary_cache_service.dictionary_exists? raise "The dictionary associated with key '#{dictionary_cache_service.key}' already exists." end end |
.validate_dictionary_reference_does_not_exist(dictionary_cache_service:) ⇒ Object
23 24 25 26 27 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 23 def validate_dictionary_reference_does_not_exist(dictionary_cache_service:) if dictionary_cache_service.dictionary_reference? raise "A dictionary reference associated with key '#{dictionary_cache_service.key}' already exists." end end |
.validate_dictionary_source_does_not_exist(dictionary_cache_service:) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 10 def validate_dictionary_source_does_not_exist(dictionary_cache_service:) # If a dictionary_reference exists, the dictionary_source must exist. if dictionary_cache_service.dictionary_reference? raise "The dictionary source associated with key '#{dictionary_cache_service.key}' already exists." end end |
Instance Method Details
#validate_dictionary_does_not_exist(dictionary_cache_service:) ⇒ Object (private)
17 18 19 20 21 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 17 def validate_dictionary_does_not_exist(dictionary_cache_service:) if dictionary_cache_service.dictionary_exists? raise "The dictionary associated with key '#{dictionary_cache_service.key}' already exists." end end |
#validate_dictionary_reference_does_not_exist(dictionary_cache_service:) ⇒ Object (private)
23 24 25 26 27 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 23 def validate_dictionary_reference_does_not_exist(dictionary_cache_service:) if dictionary_cache_service.dictionary_reference? raise "A dictionary reference associated with key '#{dictionary_cache_service.key}' already exists." end end |
#validate_dictionary_source_does_not_exist(dictionary_cache_service:) ⇒ Object (private)
10 11 12 13 14 15 |
# File 'lib/LittleWeasel/modules/dictionary_validatable.rb', line 10 def validate_dictionary_source_does_not_exist(dictionary_cache_service:) # If a dictionary_reference exists, the dictionary_source must exist. if dictionary_cache_service.dictionary_reference? raise "The dictionary source associated with key '#{dictionary_cache_service.key}' already exists." end end |