snor v0.4.0 Snor.Utils

Util functions to be used internally

Link to this section Summary

Functions

Get a deeply nested value from a map

Given a map, stringify all the keys

Link to this section Functions

Link to this function

deep_get(data, path, default)

deep_get(map(), String.t(), any()) :: any()

Get a deeply nested value from a map

Examples

iex> Snor.Utils.deep_get(%{"a" => 1}, "a", "")
1
iex> Snor.Utils.deep_get(%{"a" => %{"b" => :ok}}, "a.b", :error)
:ok
iex> Snor.Utils.deep_get(%{}, "a.b", "NOT_FOUND")
"NOT_FOUND"
Link to this function

deep_stringify(map)

deep_stringify(%{optional(any()) => any()}) :: %{
  optional(String.t()) => any()
}

Given a map, stringify all the keys

Examples

iex> Snor.Utils.deep_stringify(%{})
%{}
iex> Snor.Utils.deep_stringify(%{a: 4})
%{"a" => 4}
iex> Snor.Utils.deep_stringify(%{a: [%{b: 1}]})
%{"a" => [%{"b" => 1}]}