View Source Rivet.Utils.Callbacks (rivet_utils v2.0.1)
Contributor: Brandon Gillespie
Summary
Functions
iex> do_callback(%{callbacks: nil}, nil, nil)
:error
iex> do_callback(%{callbacks: %{mine: fn _, x -> {:ok, x} end}}, :mine, :narf)
{:ok, :narf}
iex> do_callback(%{callbacks: %{not: fn _, x -> x end}}, :diff, :narf)
:error
iex> do_callback(nil, :diff, :narf)
:error
iex> %{red: func} = init_callbacks([:red])
%{red: func}
iex> init_callbacks(nil)
nil
iex> %{thisone: func} = put_callback(%{}, :thisone)
...> is_function(func)
true
iex> take_callbacks(%{callbacks: %{one: 1, two: 2}}, [:two])
%{two: 2}
iex> take_callbacks(%{callbacks: %{one: 1, two: 2}}, [])
nil
Functions
iex> do_callback(%{callbacks: nil}, nil, nil)
:error
iex> do_callback(%{callbacks: %{mine: fn _, x -> {:ok, x} end}}, :mine, :narf)
{:ok, :narf}
iex> do_callback(%{callbacks: %{not: fn _, x -> x end}}, :diff, :narf)
:error
iex> do_callback(nil, :diff, :narf)
:error
iex> %{red: func} = init_callbacks([:red])
%{red: func}
iex> init_callbacks(nil)
nil
iex> %{thisone: func} = put_callback(%{}, :thisone)
...> is_function(func)
true
iex> take_callbacks(%{callbacks: %{one: 1, two: 2}}, [:two])
%{two: 2}
iex> take_callbacks(%{callbacks: %{one: 1, two: 2}}, [])
nil