Module: Enumerize::Hooks::UniquenessValidator

Defined in:
lib/enumerize/hooks/uniqueness.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, name, value) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/enumerize/hooks/uniqueness.rb', line 9

def validate_each(record, name, value)
  klass = record.to_model.class

  if klass.respond_to?(:enumerized_attributes) && (attr = klass.enumerized_attributes[name])
    value = attr.find_value(value).try(:value)
  end

  super(record, name, value)
end