Class: Valcro::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/valcro/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_list = ErrorList.new) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
# File 'lib/valcro/runner.rb', line 6

def initialize(error_list = ErrorList.new)
  @validators = []
  @error_list = error_list
end

Instance Attribute Details

#error_listObject

Returns the value of attribute error_list.



5
6
7
# File 'lib/valcro/runner.rb', line 5

def error_list
  @error_list
end

#validatorsObject

Returns the value of attribute validators.



5
6
7
# File 'lib/valcro/runner.rb', line 5

def validators
  @validators
end

Instance Method Details

#add_validator(validator) ⇒ Object



16
17
18
# File 'lib/valcro/runner.rb', line 16

def add_validator(validator)
  @validators << validator
end

#clear!Object



11
12
13
14
# File 'lib/valcro/runner.rb', line 11

def clear!
  @validators.clear
  @error_list.clear!
end

#validateObject



20
21
22
23
24
# File 'lib/valcro/runner.rb', line 20

def validate
  @validators.each do |validator|
    validator.call error_list
  end
end