Module: NoBrainer::Document::Validation::Uniqueness::ClassMethods
- Defined in:
- lib/no_brainer/document/validation/uniqueness.rb
Instance Method Summary collapse
- #_uniqueness_key_name_from_params(params) ⇒ Object
- #inherited(subclass) ⇒ Object
- #validates_uniqueness_of(*attr_names) ⇒ Object
Instance Method Details
#_uniqueness_key_name_from_params(params) ⇒ Object
40 41 42 43 44 |
# File 'lib/no_brainer/document/validation/uniqueness.rb', line 40 def _uniqueness_key_name_from_params(params) ['uniq', NoBrainer.current_db, self.table_name, *params.map { |k,v| [k.to_s, (v = v.to_s; v.empty? ? 'nil' : v)] }.sort ].join(':') end |
#inherited(subclass) ⇒ Object
50 51 52 53 |
# File 'lib/no_brainer/document/validation/uniqueness.rb', line 50 def inherited(subclass) subclass.unique_validators = self.unique_validators.dup super end |
#validates_uniqueness_of(*attr_names) ⇒ Object
46 47 48 |
# File 'lib/no_brainer/document/validation/uniqueness.rb', line 46 def validates_uniqueness_of(*attr_names) validates_with(UniquenessValidator, _merge_attributes(attr_names)) end |