Remove ActiveRecord::AttributeAssignment#assign_nested_parameter_attributes
The private `#assign_nested_parameter_attributes` was introduced in [774ff18][] (Dec 15, 2011), moved to `ActiveRecord::AttributeAssignment` in [ceb33f8][] (also Dec 15, 2011), then most recently modified in [2606fb3][] (Jan 23, 2015) when `ActiveModel::AttributeAssignment` was extracted. Support for `accepts_nested_attributes_for` (introduced in [ec8f045][] Feb 1, 2009) pre-dates those commits, and has evolved enough to cover this behavior in other ways. With its removal, Active Record's test suite still passes, so if it's a crucial piece of code to retain, we should expand the suite to exercise it. [774ff18]:774ff18c09
[ceb33f8]:ceb33f8493
[2606fb3]:2606fb3397
[ec8f045]:ec8f045844
This commit is contained in:
parent
eac48e95db
commit
ded026b6c9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user