Surgex.Parser.IncludeParser (Surgex v6.0.1)

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.

Summary

Functions

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

Types

errors()

@type errors() :: :invalid_relationship_path | :invalid_input

path()

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

Functions

flatten(input, key)

@spec 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}