View Source Carve.Links (Carve v0.3.0)

Carve.Links provides functionality for retrieving and processing links between different entities.

This module is responsible for:

  • Fetching links for entities based on their IDs or data structures
  • Handling circular references and preventing infinite loops
  • Normalizing and preparing the final result set of links

It works in conjunction with the view modules created using Carve.View to generate a complete set of links for any given entity or set of entities.

Summary

Functions

Retrieves links for a given module and data or list of data.

Retrieves links for a given module and ID or list of IDs.

Prepares the final result set by flattening, removing nil values, eliminating duplicates, and applying the whitelist filter if provided.

Functions

Link to this function

prepare_result(result, whitelist \\ nil)

View Source

Prepares the final result set by flattening, removing nil values, eliminating duplicates, and applying the whitelist filter if provided.

Parameters

  • result: A list of link maps
  • whitelist: An optional list of allowed link types

Returns

A cleaned, uniquified, and optionally filtered list of link maps.

Examples

iex> result = [[%{type: :team, id: "abc"}, nil], [%{type: :profile, id: "def"}], %{type: :team, id: "abc"}] iex> Carve.Links.prepare_result(result, [:team]) [%{type: :team, id: "abc"}]