Module: ActiveRecordExtensions::ValidationReflection::ClassMethods

Includes:
ActiveRecordExtensions::ValidationReflection
Defined in:
lib/vendor/plugins/validation_reflection/lib/validation_reflection.rb

Constant Summary

Constants included from ActiveRecordExtensions::ValidationReflection

CONFIG_PATH, CORE_VALIDATONS

Instance Method Summary collapse

Methods included from ActiveRecordExtensions::ValidationReflection

#included, #install, #load_config

Instance Method Details

#reflect_on_all_validationsObject

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



107
108
109
# File 'lib/vendor/plugins/validation_reflection/lib/validation_reflection.rb', line 107

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.



112
113
114
115
116
# File 'lib/vendor/plugins/validation_reflection/lib/validation_reflection.rb', line 112

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