API Reference exnew v0.1.2
Modules
iex> {:module, module, _, _} = defmodule Foobar do
...> use Exnew
...> defstruct [:c, :d]
...>
...> @impl true
...> def handle_new(%{c: 1, d: 2}), do: {:ok, %{c: 2, d: 1}}
...> def handle_new(%{c: 3, d: 4}), do: {:ok, %{c: 3, d: 4}}
...> def handle_new(_), do: {:error, :unmatched}
...> end
iex> module.new(%{c: 1, d: 2, e: 3}) |> Map.from_struct()
%{c: 2, d: 1}
iex> module.new([])
** (ArgumentError) [:unmatched] %{}