Class: Roart::Validations::Validators
- Inherits:
-
Object
- Object
- Roart::Validations::Validators
- Defined in:
- lib/roart/validations.rb
Instance Method Summary collapse
- #add(validator) ⇒ Object
-
#initialize ⇒ Validators
constructor
A new instance of Validators.
- #validate(obj) ⇒ Object
Constructor Details
#initialize ⇒ Validators
Returns a new instance of Validators.
64 65 66 |
# File 'lib/roart/validations.rb', line 64 def initialize @validators = [] end |
Instance Method Details
#add(validator) ⇒ Object
68 69 70 |
# File 'lib/roart/validations.rb', line 68 def add(validator) @validators << validator end |
#validate(obj) ⇒ Object
72 73 74 75 |
# File 'lib/roart/validations.rb', line 72 def validate(obj) obj.errors.clear @validators.each{|validator| validator.call(obj)} end |