View Source Rivet.Utils.Callbacks (rivet_utils v1.0.4)
Contributor: Brandon Gillespie
Link to this section 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
Link to this section 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