class ActiveModel::Validations::ConfirmationValidator

:nodoc:

def confirmation_value_equal?(record, attribute, value, confirmed)

def confirmation_value_equal?(record, attribute, value, confirmed)
  if !options[:case_sensitive] && value.is_a?(String)
    value.casecmp(confirmed) == 0
  else
    value == confirmed
  end
end

def initialize(options)

:nodoc:
def initialize(options)
  super({ case_sensitive: true }.merge!(options))
  setup!(options[:class])
end

def setup!(klass)

def setup!(klass)
  klass.send(:attr_reader, *attributes.map do |attribute|
    :"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation")
  end.compact)
  klass.send(:attr_writer, *attributes.map do |attribute|
    :"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation=")
  end.compact)
end

def validate_each(record, attribute, value)

def validate_each(record, attribute, value)
  if (confirmed = record.send("#{attribute}_confirmation"))
    unless confirmation_value_equal?(record, attribute, value, confirmed)
      human_attribute_name = record.class.human_attribute_name(attribute)
      record.errors.add(:"#{attribute}_confirmation", :confirmation, options.except(:case_sensitive).merge!(attribute: human_attribute_name))
    end
  end
end