Module: LittleWeasel::Preprocessors::WordPreprocessorValidatable
- Defined in:
- lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb
Overview
This module validates word preprocessor types. rubocop: disable Layout/LineLength
Class Method Summary collapse
-
.validate_word_preprocessor(word_preprocessor:) ⇒ Object
:reek:ManualDispatch - ignored, this is duck-typing not ‘simulated polymorphism’ :reek:TooManyStatements - ignored, “too many statements” is easier to understand than arbitrarily breaking all this down into individual methods.
- .validation_error_message(object:, respond_to:) ⇒ Object
Instance Method Summary collapse
-
#validate_word_preprocessor(word_preprocessor:) ⇒ Object
private
:reek:ManualDispatch - ignored, this is duck-typing not ‘simulated polymorphism’ :reek:TooManyStatements - ignored, “too many statements” is easier to understand than arbitrarily breaking all this down into individual methods.
- #validation_error_message(object:, respond_to:) ⇒ Object private
Class Method Details
.validate_word_preprocessor(word_preprocessor:) ⇒ Object
:reek:ManualDispatch - ignored, this is duck-typing not ‘simulated polymorphism’ :reek:TooManyStatements - ignored, “too many statements” is easier to understand than arbitrarily breaking all this down into individual methods
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb', line 12 def validate_word_preprocessor(word_preprocessor:) # You can use your own word preprocessor types as long as they quack # correctly; however, you are responsible for the behavior of these # required methods/ attributes. It's probably better to follow the # pattern of existing word preprocessor objects and inherit from # Preprocessors::WordPreprocessor. word_preprocessor_class = word_preprocessor.class # class methods raise (object: word_preprocessor_class, respond_to: '.preprocess') unless word_preprocessor_class.respond_to?(:preprocess) raise (object: word_preprocessor_class, respond_to: '.preprocess?') unless word_preprocessor_class.respond_to?(:preprocess?) # instance methods raise (object: word_preprocessor_class, respond_to: '#preprocess') unless word_preprocessor.respond_to?(:preprocess) raise (object: word_preprocessor_class, respond_to: '#preprocess?') unless word_preprocessor.respond_to?(:preprocess?) raise (object: word_preprocessor_class, respond_to: '#preprocessor_off?') unless word_preprocessor.respond_to?(:preprocessor_off?) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on') unless word_preprocessor.respond_to?(:preprocessor_on) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on=') unless word_preprocessor.respond_to?(:preprocessor_on=) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on?') unless word_preprocessor.respond_to?(:preprocessor_on?) end |
.validation_error_message(object:, respond_to:) ⇒ Object
34 35 36 |
# File 'lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb', line 34 def (object:, respond_to:) "Argument word_preprocessor: does not respond to: #{object}#{respond_to}" end |
Instance Method Details
#validate_word_preprocessor(word_preprocessor:) ⇒ Object (private)
:reek:ManualDispatch - ignored, this is duck-typing not ‘simulated polymorphism’ :reek:TooManyStatements - ignored, “too many statements” is easier to understand than arbitrarily breaking all this down into individual methods
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb', line 12 def validate_word_preprocessor(word_preprocessor:) # You can use your own word preprocessor types as long as they quack # correctly; however, you are responsible for the behavior of these # required methods/ attributes. It's probably better to follow the # pattern of existing word preprocessor objects and inherit from # Preprocessors::WordPreprocessor. word_preprocessor_class = word_preprocessor.class # class methods raise (object: word_preprocessor_class, respond_to: '.preprocess') unless word_preprocessor_class.respond_to?(:preprocess) raise (object: word_preprocessor_class, respond_to: '.preprocess?') unless word_preprocessor_class.respond_to?(:preprocess?) # instance methods raise (object: word_preprocessor_class, respond_to: '#preprocess') unless word_preprocessor.respond_to?(:preprocess) raise (object: word_preprocessor_class, respond_to: '#preprocess?') unless word_preprocessor.respond_to?(:preprocess?) raise (object: word_preprocessor_class, respond_to: '#preprocessor_off?') unless word_preprocessor.respond_to?(:preprocessor_off?) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on') unless word_preprocessor.respond_to?(:preprocessor_on) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on=') unless word_preprocessor.respond_to?(:preprocessor_on=) raise (object: word_preprocessor_class, respond_to: '#preprocessor_on?') unless word_preprocessor.respond_to?(:preprocessor_on?) end |
#validation_error_message(object:, respond_to:) ⇒ Object (private)
34 35 36 |
# File 'lib/LittleWeasel/preprocessors/word_preprocessor_validatable.rb', line 34 def (object:, respond_to:) "Argument word_preprocessor: does not respond to: #{object}#{respond_to}" end |