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
- #append(&block) ⇒ Object
-
#initialize(klass) ⇒ EachValidator
constructor
A new instance of EachValidator.
- #validate ⇒ Object
Constructor Details
#initialize(klass) ⇒ EachValidator
Returns a new instance of EachValidator.
6 7 8 |
# File 'lib/cavalry/validator/each_validator.rb', line 6 def initialize(klass) @source_class = klass 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
#append(&block) ⇒ Object
10 11 12 |
# File 'lib/cavalry/validator/each_validator.rb', line 10 def append(&block) @source_class.class_eval(&block) end |
#validate ⇒ Object
14 15 16 17 |
# File 'lib/cavalry/validator/each_validator.rb', line 14 def validate install_force_check_belongs_to_association if Cavalry.config.force_check_belongs_to_association && @source_class.respond_to?(:reflections) source_class.all.flat_map {|record| validate_record(record) }.compact end |