Current section

Files

Jump to
static_context priv templates static_context get!.ex.eex
Raw

priv/templates/static_context/get!.ex.eex

@doc """
Fetches a single `<%= inspect(struct) %>` by string `id`.
Raises `ArgumentError` if not found, `FunctionClauseError` if `id` is not a binary.
"""
def get!(id) when is_binary(id) do
case Enum.find(entries(), &(&1.id == id)) do
nil -> raise ArgumentError, "No #{__MODULE__} entry found with id: #{inspect(id)}"
entry -> entry
end
end