Module: ActiveRecordExtensions::ValidationReflection::ClassMethods
- Defined in:
- lib/validation_reflection.rb
Constant Summary
Constants included from ActiveRecordExtensions::ValidationReflection
Instance Method Summary collapse
-
#reflect_on_all_validations ⇒ Object
Returns an array of MacroReflection objects for all validations in the class.
-
#reflect_on_validations_for(attr_name) ⇒ Object
Returns an array of MacroReflection objects for all validations defined for the field
attr_name
.
Methods included from ActiveRecordExtensions::ValidationReflection
#included, #install, #load_config
Instance Method Details
#reflect_on_all_validations ⇒ Object
Returns an array of MacroReflection objects for all validations in the class
109 110 111 |
# File 'lib/validation_reflection.rb', line 109 def reflect_on_all_validations self.read_inheritable_attribute(:validations) || [] end |
#reflect_on_validations_for(attr_name) ⇒ Object
Returns an array of MacroReflection objects for all validations defined for the field attr_name
.
114 115 116 117 118 |
# File 'lib/validation_reflection.rb', line 114 def reflect_on_validations_for(attr_name) self.reflect_on_all_validations.select do |reflection| reflection.name == attr_name.to_sym end end |