BootEnv v0.1.1 BootEnv.Util View Source

Link to this section Summary

Functions

Strict get_in/2 function to fetch deep data from map/keyword list

Safe put_in/2 function to put value to nested map

Link to this section Functions

Strict get_in/2 function to fetch deep data from map/keyword list

Examples

iex> BootEnv.Util.deep_get!(%{foo: [bar: 123]}, [:foo, :bar])
123

iex> BootEnv.Util.deep_get!(%{foo: [bar: 123]}, [:foo, :bar, :baz])
** (BootEnv.Exception.InvalidConfig) 123

iex> BootEnv.Util.deep_get!(%{foo: [bar: 123]}, [:foo, :hello])
** (BootEnv.Exception.MissingParam) :hello

iex> BootEnv.Util.deep_get!(%{foo: [bar: 123]}, [:hello])
** (BootEnv.Exception.MissingParam) :hello

Safe put_in/2 function to put value to nested map

Examples

iex> BootEnv.Util.deep_put(%{foo: 123}, [:bar, :baz], 321)
%{foo: 123, bar: %{baz: 321}}

iex> BootEnv.Util.deep_put(%{foo: %{hello: 123}}, [:foo, :bar, :baz], 321)
%{foo: %{hello: 123, bar: %{baz: 321}}}