def link_child_to_parent(operation)
    child_collection = operation.klass.send("#{operation.klass_name}") || []
    child_collection << operation.child_klass
    operation.klass.send("#{operation.klass_name}=", child_collection)

    # Attach the parent to the child
    parent_meta = @class_metadata[operation.klass.class.to_s][operation.klass_name]
    child_meta = @class_metadata[operation.child_klass.class.to_s]
    # Find the matching relationship on the child object
    child_properties = Helpers.normalize_to_hash(
        child_meta.select { |k, prop|
          prop.nav_prop &&
              prop.association.relationship == parent_meta.association.relationship })

    child_property_to_set = child_properties.keys.first # There should be only one match
    # TODO: Handle many to many scenarios where the child property is an enumerable
    operation.child_klass.send("#{child_property_to_set}=", operation.klass)
  end
def link_child_to_parent(operation)
    child_collection = operation.klass.send("#{operation.klass_name}") || []
    child_collection << operation.child_klass
    operation.klass.send("#{operation.klass_name}=", child_collection)

    # Attach the parent to the child
    parent_meta = @class_metadata[operation.klass.class.to_s][operation.klass_name]
    child_meta = @class_metadata[operation.child_klass.class.to_s]
    # Find the matching relationship on the child object
    child_properties = Helpers.normalize_to_hash(
        child_meta.select { |k, prop|
          prop.nav_prop &&
              prop.association.relationship == parent_meta.association.relationship })

    child_property_to_set = child_properties.keys.first # There should be only one match
    # TODO: Handle many to many scenarios where the child property is an enumerable
    operation.child_klass.send("#{child_property_to_set}=", operation.klass)
  end
Used to link a child object to its parent and vice-versa after a add_link operation