View Source StepFlow.Map (StepFlow v1.8.0)
Extend Map with some additional functions.
Summary
Functions
Get a key matching on an atom or a string.
Replace an item in a map, with atom or string keys.
Functions
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"
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"}