Recon

Module recon_map

This module handles formatting maps.

Authors: bartlomiej.gorny@erlang-solutions.com.

Description

This module handles formatting maps. It allows for trimming output to selected fields, or to nothing at all. It also adds a label to a printout. To set up a limit for a map, you need to give recon a way to tell the map you want to trim from all the other maps, so you have to provide something like a 'type definition'. It can be either another map which is compared to the arg, or a fun.

Data Types

limit()

limit() = all | none | atom() | binary() | [any()]

map_label()

map_label() = atom()

pattern()

pattern() = map() | function()

Function Index

clear/0remove all imported definitions, destroy the table, clean up.
is_active/0quickly check if we want to do any record formatting.
limit/3Limit output to selected keys of a map (can be 'none', 'all', a key or a list of keys).
list/0prints out all "known" map definitions and their limit settings.
remove/1remove a given map entry.
rename/2rename a given map entry, which allows to to change priorities for matching.

Function Details

clear/0

clear() -> any()

remove all imported definitions, destroy the table, clean up

is_active/0

is_active() -> boolean()

quickly check if we want to do any record formatting

limit/3

limit(Label::map_label(), Pattern::pattern(), Limit::limit()) -> ok | {error, any()}

Limit output to selected keys of a map (can be 'none', 'all', a key or a list of keys). Pattern selects maps to process: a "pattern" is just a map, and if all key/value pairs of a pattern are present in a map (in other words, the pattern is a subset), then we say the map matches and we process it accordingly (apply the limit).

Patterns are applied in alphabetical order, until a match is found.

Instead of a pattern you can also provide a function which will take a map and return a boolean.

list/0

list() -> any()

prints out all "known" map definitions and their limit settings. Printout tells a map's name, the matching fields required, and the limit options.

remove/1

remove(Label::map_label()) -> true

remove a given map entry

rename/2

rename(Name::map_label(), NewName::map_label()) -> renamed | missing

rename a given map entry, which allows to to change priorities for matching. The first argument is the current name, and the second argument is the new name.