code_corps v0.0.1 CodeCorps.Adapter.MapTransformer View Source

Module used to transform maps for the purposes of various adapters used by the application.

Link to this section Summary

Types

A format representing how a single key should be mapped from a source. The actual format is a 2 element tuple

Functions

Takes a source map and a list of tuples representing how the source map should be transformed into a new map, then applies the mapping operation on each field

Performs the inverse of &transform/2

Link to this section Types

Link to this type key_mapping() View Source
key_mapping() :: {atom(), list()[atom()]}

A format representing how a single key should be mapped from a source. The actual format is a 2 element tuple.

The first element is the destination key in the output map.

The second element is a list of keys representing the nested path to the key in the source map.

For example, the tuple:

{:target_path, ["nested", "path", "to", "source"]}

Means that, from the source map, we need to take the nested value under “nested” => “path” => “to” => “source” and then put it into the output map, as a value for the key “:target_path”.

Link to this section Functions

Link to this function transform(source_map, mapping) View Source
transform(map(), mapping()) :: map()

Takes a source map and a list of tuples representing how the source map should be transformed into a new map, then applies the mapping operation on each field.

Link to this function transform_inverse(map, mapping) View Source
transform_inverse(map(), mapping()) :: map()

Performs the inverse of &transform/2