Packages
TMap is a library for manipulating map objects, useful for master data management systems it is possible to define rules for keys/values replace, adding new keys/values by regex matching on otehr keys/values,... See Plugins direcctory for details
Current section
Files
Jump to
Current section
Files
lib/tmap.ex
defmodule TMap do
@moduledoc """
Documentation for Tmap.
"""
@doc """
apply_rules.
## Examples
"""
@spec apply_rules(map, list) :: map
def apply_rules(map, rules) do
List.foldl(rules, map,
fn cmd, acc ->
action = cmd["action"] <> "Plugin"
{new_acc, _} = Code.eval_string(action <> ".run(acc, options)",
[acc: acc, options: Map.delete(cmd, cmd["action"])], __ENV__)
new_acc
end
)
end
end