Class: Cavalry::Validator::EachValidator
- Inherits:
-
Object
- Object
- Cavalry::Validator::EachValidator
- Defined in:
- lib/cavalry/validator/each_validator.rb
Instance Attribute Summary collapse
-
#source_class ⇒ Object
readonly
Returns the value of attribute source_class.
Instance Method Summary collapse
-
#initialize(klass, &block) ⇒ EachValidator
constructor
A new instance of EachValidator.
- #validate ⇒ Object
Constructor Details
#initialize(klass, &block) ⇒ EachValidator
6 7 8 9 |
# File 'lib/cavalry/validator/each_validator.rb', line 6 def initialize(klass, &block) @source_class = klass @source_class.class_eval(&block) end |
Instance Attribute Details
#source_class ⇒ Object (readonly)
Returns the value of attribute source_class.
4 5 6 |
# File 'lib/cavalry/validator/each_validator.rb', line 4 def source_class @source_class end |
Instance Method Details
#validate ⇒ Object
11 12 13 |
# File 'lib/cavalry/validator/each_validator.rb', line 11 def validate source_class.all.flat_map {|record| validate_record(record) }.compact end |