Surgex.Parser.IncludeParser (Surgex v5.0.0) View Source

Parses the JSON API's include parameter according to the JSON API spec.

Produces a list of includes constrained to the provided relationship paths.

Link to this section Summary

Functions

Flattens the result of the parser (inclusion list) into multiple keys.

Link to this section Types

Specs

errors() :: :invalid_relationship_path | :invalid_input

Specs

path() :: atom() | String.t()

Link to this section Functions

Specs

flatten({:ok, Keyword.t()}, String.t()) :: {:ok, Keyword.t()}

Flattens the result of the parser (inclusion list) into multiple keys.

Examples

iex> IncludeParser.flatten({:ok, include: [:user]}, :include)
{:ok, include_user: true}