Class: Romanesco::Validators::Validator
- Inherits:
-
Object
- Object
- Romanesco::Validators::Validator
- Defined in:
- lib/romanesco/validators/validator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#next_step ⇒ Object
Returns the value of attribute next_step.
Instance Method Summary collapse
- #execute(object) ⇒ Object
-
#initialize(next_step = nil) ⇒ Validator
constructor
A new instance of Validator.
- #validate(object) ⇒ Object
Constructor Details
#initialize(next_step = nil) ⇒ Validator
Returns a new instance of Validator.
7 8 9 |
# File 'lib/romanesco/validators/validator.rb', line 7 def initialize(next_step=nil) @next_step = next_step end |
Instance Attribute Details
#next_step ⇒ Object
Returns the value of attribute next_step.
5 6 7 |
# File 'lib/romanesco/validators/validator.rb', line 5 def next_step @next_step end |
Instance Method Details
#execute(object) ⇒ Object
11 12 13 14 15 |
# File 'lib/romanesco/validators/validator.rb', line 11 def execute(object) modified_object = validate(object) return modified_object if next_step.nil? next_step.execute(modified_object) end |
#validate(object) ⇒ Object
17 18 19 |
# File 'lib/romanesco/validators/validator.rb', line 17 def validate(object) raise NotImplementedError end |