Unpack v0.1.6 Unpack View Source
Unpack lets you safely “unpack” any values from a nested map, struct or database object.
Link to this section Summary
Functions
Traverses nested data
map or struct in order of keys list
to return a value.
Returns nil for missing keys, unloaded associations or empty maps
Traverses nested data
map or struct in order of keys list
to return a value.
Returns given default
parameter for missing keys, unloaded associations or empty maps
Link to this section Functions
Traverses nested data
map or struct in order of keys list
to return a value.
Returns nil for missing keys, unloaded associations or empty maps.
Examples
iex> map = %{player: %{game: %{id: "game_id"}}}
iex> Unpack.get(map, [:player, :game, :id])
"game_id"
iex> struct = %{player: %Ecto.Association.NotLoaded{}}
iex> Unpack.get(struct, [:player, :game, :id])
nil