Class: Cavalry::Validator::EachValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/cavalry/validator/each_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_classObject (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

#validateObject



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