Module: ValidationReflection::ClassMethods

Includes:
ValidationReflection
Defined in:
lib/validation_reflection.rb

Constant Summary

Constants included from ValidationReflection

CORE_VALIDATONS

Instance Method Summary collapse

Methods included from ValidationReflection

#included, #install

Instance Method Details

#reflect_on_all_validationsObject

Returns an array of MacroReflection objects for all validations in the class



64
65
66
# File 'lib/validation_reflection.rb', line 64

def reflect_on_all_validations
  self.read_inheritable_attribute(:reflected_validations) || []
end

#reflect_on_validations_for(attr_name) ⇒ Object

Returns an array of MacroReflection objects for all validations defined for the field attr_name.



69
70
71
72
73
# File 'lib/validation_reflection.rb', line 69

def reflect_on_validations_for(attr_name)
  self.reflect_on_all_validations.select do |reflection|
    reflection.name == attr_name.to_sym
  end
end