Class: Romanesco::Validators::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/romanesco/validators/validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_stepObject

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

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/romanesco/validators/validator.rb', line 17

def validate(object)
  raise NotImplementedError
end