Forage.Codec.Encoder (forage v0.8.0)

Functionality to encode a Forage.Plan into a Phoenix param map for use with the ApplicationWeb.Router.Helpers.

Link to this section Summary

Functions

Encodes a forage plan into a params map.

Encode the "filter" part of a forage plan. Returns a map.

Encode the "pagination" part of a forage plan. Returns a map.

Encode the "sort" part of a forage plan. Returns a map.

Adds extra filters to a params map in the form of a list of pairs (either a list of the form [{"key", value}] or a keyword list [key: value]).

Link to this section Functions

Encodes a forage plan into a params map.

This function doesn't need to take the schema as an argument because it will never have to convert a string into an atom (the params map contains only strings and never atoms)

Link to this function

encode_filter(plan)

Encode the "filter" part of a forage plan. Returns a map.

Link to this function

encode_pagination(plan)

Encode the "pagination" part of a forage plan. Returns a map.

Link to this function

encode_sort(plan)

Encode the "sort" part of a forage plan. Returns a map.

Link to this function

with_extra_filters(params, new_filters)

Adds extra filters to a params map in the form of a list of pairs (either a list of the form [{"key", value}] or a keyword list [key: value]).

This function trades explicitness for succintness. It only suppotrs equal_to filters.