Module: ValidationReflection::ActiveModelInterface::ClassMethods

Defined in:
lib/validation_reflection/active_model.rb

Instance Method Summary collapse

Instance Method Details

#_validatorsObject



13
14
15
16
17
18
19
20
21
# File 'lib/validation_reflection/active_model.rb', line 13

def _validators
  validations = Hash.new { |h, k| h[k] = [] }

  reflect_on_all_validations.each do |reflection|
    validations[reflection.name.to_sym] << reflection
  end

  validations
end

#validatorsObject



23
24
25
# File 'lib/validation_reflection/active_model.rb', line 23

def validators
  _validators.values.flatten.uniq
end

#validators_on(attribute) ⇒ Object



27
28
29
# File 'lib/validation_reflection/active_model.rb', line 27

def validators_on(attribute)
  _validators[attribute.to_sym]
end