From b24ed15baa988a37b436bc9636bd0ecdb3ae0a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 9 Dec 2020 17:10:22 +0000 Subject: [PATCH] Rename the method to match what it is doing --- activemodel/lib/active_model/validations/numericality.rb | 2 +- activemodel/lib/active_model/validator.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 9c56417d89..da75199cc9 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -108,7 +108,7 @@ module ActiveModel end end - def read_attribute_for_validation(record, attr_name, value) + def prepare_value_for_validation(value, record, attr_name) return value if record_attribute_changed_in_place?(record, attr_name) came_from_user = :"#{attr_name}_came_from_user?" diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 9e2dee9a00..a521d79d7e 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -149,7 +149,7 @@ module ActiveModel attributes.each do |attribute| value = record.read_attribute_for_validation(attribute) next if (value.nil? && options[:allow_nil]) || (value.blank? && options[:allow_blank]) - value = read_attribute_for_validation(record, attribute, value) + value = prepare_value_for_validation(value, record, attribute) validate_each(record, attribute, value) end end @@ -167,7 +167,7 @@ module ActiveModel end private - def read_attribute_for_validation(record, attr_name, value) + def prepare_value_for_validation(value, record, attr_name) value end end