Ash.Resource extension for implementing ToonEx.Encoder protocol.

toon

Configuration for ToonEx encoder implementation.

Nested DSLs

Options

NameTypeDefaultDocs
picklist(atom) | %{optional(:private?) => boolean, optional(:sensitive?) => boolean, optional(:include) => list(atom), optional(:exclude) => list(atom), optional(:relationships?) => boolean, optional(:calculations?) => boolean, optional(:aggregates?) => boolean, optional(:format) => atom}Keys to pick from a record into a result. Accepts an explicit names list or a behaviour configuration map.

toon.compact

compact config

A step to omit fields with unwanted values (nil, for example).

Arguments

NameTypeDefaultDocs
configboolean | {:only, list(atom)} | {:except, list(atom)} | %{optional(:values) => list(any), optional(:fields) => {:only, list(atom)} | {:except, list(atom)}}Accepts true to remove any field with nil, a tagged only/except tuple to specify targeted fields or a map to configure which value or fields to work on.

toon.merge

merge values

A step to merge fixed values into a result.

Arguments

NameTypeDefaultDocs
valueslist({any, any}) | %{optional(any) => any}Values to merge into a result. Accepts a map or a tuples list.

toon.rename

rename renames

A step to rename keys in a result.

Arguments

NameTypeDefaultDocs
renameslist({any, any}) | %{optional(any) => any} | (any -> any)A mapping for renaming keys in a result. Accepts a map, a tuples list or a function.

toon.order

order sort

A step to reorder keys in a result.

Arguments

NameTypeDefaultDocs
sortboolean | (list(any) -> list(any)) | list(any)An order to apply to keys in toon. Accepts a boolean, a sort function or a list of keys in a desired order.

toon.customize

customize fun

A step to arbitrary customize a result.

Arguments

NameTypeDefaultDocs
fun(list({any, any}), map -> list({any, any}))A function to customize a result with. Receives a result and a resource record.