Method: ActiveModel::Validations#read_attribute_for_validation

Defined in:
activemodel/lib/active_model/validations.rb

#read_attribute_for_validationObject

Hook method defining how an attribute value should be retrieved. By default this is assumed to be an instance named after the attribute. Override this method in subclasses should you need to retrieve the value for a given attribute differently:

class MyClass
  include ActiveModel::Validations

  def initialize(data = {})
    @data = data
  end

  def read_attribute_for_validation(key)
    @data[key]
  end
end


371
# File 'activemodel/lib/active_model/validations.rb', line 371

alias :read_attribute_for_validation :send

Comments