StepFlow.Map (StepFlow v0.2.7) View Source

Extend Map with some additional functions.

Link to this section Summary

Functions

Get a key matching on an atom or a string.

Replace an item in a map, with atom or string keys.

Link to this section Functions

Link to this function

get_by_key_or_atom(dict, atom, default \\ nil)

View Source

Get a key matching on an atom or a string.

Default value can be specified.

Examples

iex> StepFlow.Map.get_by_key_or_atom(%{key: "value"}, :key)
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{"key" => "value"}, :key)
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{key: "value"}, "key")
"value"

iex> StepFlow.Map.get_by_key_or_atom(%{"key" => "value"}, "key")
"value"
Link to this function

replace_by_atom(dict, atom, value)

View Source

Replace an item in a map, with atom or string keys.

Examples

iex> StepFlow.Map.replace_by_atom(%{key: "value"}, :key, "replaced_value")
%{key: "replaced_value"}

iex> StepFlow.Map.replace_by_atom(%{"key" => "value"}, :key, "replaced_value")
%{key: "replaced_value"}

iex> StepFlow.Map.replace_by_atom(%{"key" => "value"}, "key", "replaced_value")
%{key: "replaced_value"}