ExToolkit.Map (ExToolkit v0.12.4)
View SourceThis module provides utilities for working with maps.
Summary
Functions
Recursively converts a struct into a plain map, transforming all nested structs, maps, and lists along the way.
Functions
Recursively converts a struct into a plain map, transforming all nested structs, maps, and lists along the way.
Only accepts a struct at the top level. If a non-struct is passed, it will raise a FunctionClauseError
.
If you don't want to do a deep recursive conversion you should use Map.from_struct/1
.
Examples
iex> outer = %URI{host: "test", scheme: %{info: %URI{host: 42, authority: nil, fragment: nil, path: nil, port: nil, query: nil, scheme: nil, userinfo: nil}}}
iex> ExToolkit.Map.deep_from_struct(outer)
%{
host: "test",
scheme: %{info: %{host: 42, authority: nil, fragment: nil, path: nil, port: nil, query: nil, scheme: nil, userinfo: nil}},
authority: nil,
fragment: nil,
path: nil,
port: nil,
query: nil,
userinfo: nil
}