Module: Graphiti::ActiveGraph::Concerns::PathRelationships

Included in:
Deserializer
Defined in:
lib/graphiti/active_graph/concerns/path_relationships.rb

Instance Method Summary collapse

Instance Method Details

#add_path_id_to_relationships!(params) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/graphiti/active_graph/concerns/path_relationships.rb', line 3

def add_path_id_to_relationships!(params)
  return params if path_relationships_updated?
  detect_conflict(:id, @params[:id]&.to_s, attributes[:id]&.to_s)
  path_map.each do |rel_name, path_value|
    body_value = relationships.dig(rel_name, :attributes, :id)
    if body_value
      detect_conflict(rel_name, path_value&.to_s, body_value&.to_s)
    else
      update_params(params, rel_name, path_value)
      update_realationships(rel_name, path_value)
    end
  end
  path_relationships_updated!
  params
end