class ViewModel::ActiveRecord::NestedControllerBase::ParentProxyModel
def initialize(parent, association_data, changed_children)
def initialize(parent, association_data, changed_children) @parent = parent @association_data = association_data @changed_children = changed_children end
def serialize(json, serialize_context:)
def serialize(json, serialize_context:) ViewModel::Callbacks.wrap_serialize(parent, context: serialize_context) do child_context = parent.context_for_child(association_data.association_name, context: serialize_context) json.set!(ViewModel::ID_ATTRIBUTE, parent.id) json.set!(ViewModel::BULK_UPDATE_ATTRIBUTE) do if association_data.referenced? && !association_data.owned? if association_data.collection? json.array!(changed_children) do |child| ViewModel.serialize_as_reference(child, json, serialize_context: child_context) end else ViewModel.serialize_as_reference(changed_children, json, serialize_context: child_context) end else ViewModel.serialize(changed_children, json, serialize_context: child_context) end end end end