提交 5bd96de6 编写于 作者: C Carlos Antonio da Silva

Extract nested parameter assignment to a separate method

上级 9f885212
......@@ -104,8 +104,7 @@ def assign_attributes(new_attributes, options = {})
end
end
# assign any deferred nested attributes after the base attributes have been set
nested_parameter_attributes.each { |k,v| _assign_attribute(k, v) }
assign_nested_parameter_attributes(nested_parameter_attributes) unless nested_parameter_attributes.empty?
assign_multiparameter_attributes(multi_parameter_attributes) unless multi_parameter_attributes.empty?
ensure
@mass_assignment_options = previous_options
......@@ -133,6 +132,11 @@ def _assign_attribute(k, v)
end
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
......@@ -252,6 +256,5 @@ def type_cast_attribute_value(multiparameter_name, value)
def find_parameter_position(multiparameter_name)
multiparameter_name.scan(/\(([0-9]*).*\)/).first.first.to_i
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册