Remove Hash allocation

merge! takes a Hash as an argument. Rather than allocating a Hash,
just use two different `=` calls, to achieve the same result.
This commit is contained in:
rubic0n 2021-02-18 00:35:31 -06:00
parent a623252c59
commit 006322cff7
1 changed files with 4 additions and 1 deletions

View File

@ -11,7 +11,10 @@ class ActiveModel::Serializer::Reflection
def build_association(parent_serializer, parent_serializer_options, include_slice = {}) def build_association(parent_serializer, parent_serializer_options, include_slice = {})
serializer = options[:serializer] serializer = options[:serializer]
parent_serializer_options.merge!(named_contexts: serializer._named_contexts, context_extensions: serializer._context_extensions) if serializer.respond_to?(:_named_contexts) if serializer.respond_to?(:_named_contexts)
parent_serializer_options[:named_contexts] = serializer._named_contexts
parent_serializer_options[:context_extensions] = serializer._context_extensions
end
association_options = { association_options = {
parent_serializer: parent_serializer, parent_serializer: parent_serializer,