Skip to content

Commit

Permalink
Rename the method to match what it is doing
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 9, 2020
1 parent fe8db70 commit 84e3192
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/validations/numericality.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def allow_only_integer?(record)
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?"
Expand Down
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def validate(record)
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
Expand All @@ -167,7 +167,7 @@ def check_validity!
end

private
def read_attribute_for_validation(record, attr_name, value)
def prepare_value_for_validation(value, record, attr_name)
value
end
end
Expand Down

0 comments on commit 84e3192

Please sign in to comment.