Class: SimplyStored::Couch::Validations::ValidatesUniquenessOf
- Inherits:
-
Validatable::ValidationBase
- Object
- Validatable::ValidationBase
- SimplyStored::Couch::Validations::ValidatesUniquenessOf
- Defined in:
- lib/simply_stored/couch/validations.rb
Instance Method Summary collapse
Instance Method Details
#message(instance) ⇒ Object
50 51 52 |
# File 'lib/simply_stored/couch/validations.rb', line 50 def (instance) super || "#{attribute.to_s.try(:humanize) || attribute.to_s} is already taken" end |
#valid?(instance) ⇒ Boolean
40 41 42 43 44 45 46 47 48 |
# File 'lib/simply_stored/couch/validations.rb', line 40 def valid?(instance) other_instance = instance.class.send("find_by_#{attribute}", instance.send(attribute)) if other_instance && other_instance != instance && other_instance.send(attribute) == instance.send(attribute) false else true end end |