Class: DataMapper::Matchers::ValidateUniquenessOf
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- DataMapper::Matchers::ValidateUniquenessOf
- Defined in:
- lib/dm/matchers/validate_uniqueness_of.rb
Instance Method Summary collapse
Methods inherited from ValidationMatcher
#description, #failure_message, #initialize, #negative_failure_message, set_default_msg_reg, set_validation_subject, #with_message
Constructor Details
This class inherits a constructor from DataMapper::Matchers::ValidationMatcher
Instance Method Details
#matches?(model) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dm/matchers/validate_uniqueness_of.rb', line 10 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.[:message] true end |