Sha256: 76100ac8ef0a770bd9cec02bacecbd2fabe8b3809b12c15942f4b7d15d9f9137
Contents?: true
Size: 707 Bytes
Versions: 11
Compression:
Stored size: 707 Bytes
Contents
module DataMapper module Matchers def validate_uniqueness_of(property) ValidateUniquenessOf.new(property) end class ValidateUniquenessOf < ValidationMatcher set_validation_subject "uniqueness" def matches?(model) model_class = model.is_a?(Class) ? model : model.class validators = model_class.validators.contexts[:default] uniqueness_of = validators.find do |validator| validator.is_a? DataMapper::Validations::UniquenessValidator and validator.field_name == @property end return false unless uniqueness_of return false if @msg and @msg != uniqueness_of.options[:message] true end end end end
Version data entries
11 entries across 11 versions & 2 rubygems