DarkMatter.Structs (DarkMatter v1.1.4) View Source

Utils for working with structs.

Link to this section Summary

Functions

Reduce a map with only non nil default values for a given module.

Determine keys for a given module or raises ArgumentError.

Determine if a given key is a meta map property.

Link to this section Functions

Link to this function

defaults(module)

View Source (since 1.1.3)

Specs

defaults(module()) :: %{required(atom()) => any()}

Reduce a map with only non nil default values for a given module.

Specs

keys(module() | struct()) :: [atom()]

Determine keys for a given module or raises ArgumentError.

Examples

iex> keys(IO.Stream)
[:device, :line_or_bytes, :raw]

iex> keys(%IO.Stream{})
[:device, :line_or_bytes, :raw]

iex> keys(%{})
** (FunctionClauseError) no function clause matching in DarkMatter.Structs.keys/1

Specs

meta_key?(atom()) :: boolean()

Determine if a given key is a meta map property.

Examples

iex> meta_key?(:__meta__)
true

iex> meta_key?(:__struct__)
true

iex> meta_key?(:non_meta)
false