Merge pull request #49678 from seanpdoyle/remove-unnecessary-method-from-attribute-assignment

Remove `ActiveRecord::AttributeAssignment#assign_nested_parameter_attributes`
This commit is contained in:
Rafael Mendonça França 2024-01-10 13:39:17 -05:00 committed by GitHub
commit 75ba520b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 9 deletions

View File

@ -4,29 +4,21 @@ module ActiveRecord
module AttributeAssignment
private
def _assign_attributes(attributes)
multi_parameter_attributes = nested_parameter_attributes = nil
multi_parameter_attributes = nil
attributes.each do |k, v|
key = k.to_s
if key.include?("(")
(multi_parameter_attributes ||= {})[key] = v
elsif v.is_a?(Hash)
(nested_parameter_attributes ||= {})[key] = v
else
_assign_attribute(key, v)
end
end
assign_nested_parameter_attributes(nested_parameter_attributes) if nested_parameter_attributes
assign_multiparameter_attributes(multi_parameter_attributes) if multi_parameter_attributes
end
# Assign any deferred nested attributes after the base attributes have been set.
def assign_nested_parameter_attributes(pairs)
pairs.each { |k, v| _assign_attribute(k, v) }
end
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate