Sha256: e27eb5a78ef216ad58699dde821392a078a5df3c49d809d262bae6a22de7e5a6
Contents?: true
Size: 977 Bytes
Versions: 9
Compression:
Stored size: 977 Bytes
Contents
module ActiveData module Model module Associations module Validations def valid_ancestry? errors.clear validate_nested! run_validations! end alias_method :validate_ancestry, :valid_ancestry? def invalid_ancestry? !valid_ancestry? end def validate_ancestry! valid_ancestry? || raise_validation_error end private def validate_nested! association_names.each do |name| association = association(name) invalid_block = if association.reflection.klass.method_defined?(:invalid_ansestry?) ->(object) { object.invalid_ansestry? } else ->(object) { object.invalid? } end ActiveData::Model::Validations::NestedValidator .validate_nested(self, name, association.target, &invalid_block) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems