Module: GLiveValidator::ActiveRecordExtensions::ValidationReflection::ClassMethods

Defined in:
lib/g_live_validator/active_record_extensions.rb

Instance Method Summary collapse

Instance Method Details

#reflect_on_all_validationsObject

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



56
57
58
# File 'lib/g_live_validator/active_record_extensions.rb', line 56

def reflect_on_all_validations
  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 (expects a symbol)



61
62
63
64
65
# File 'lib/g_live_validator/active_record_extensions.rb', line 61

def reflect_on_validations_for( attr_name )
  reflect_on_all_validations.find_all do |reflection|
    reflection.name.to_s == attr_name.to_s
  end
end