View Source Flamel.Wrap (flamel v1.4.0)

Summary

Functions

Takes a value and wraps it in a :cont tuple

Takes a value and wraps it in a :continue tuple

Takes a value and wraps it in a :error tuple

Takes a value and wraps it in a :noreply tuple

Takes a value and wraps it in a :ok tuple

Takes an {:ok, value} or {:error, message} tuple and returns the value

Takes an {:ok, value} tuple and returns the value

Takes an {:error, value} tuple and returns the value or nil

Takes an {:ok, value} tuple and returns the value

Takes an {:ok, value} tuple and returns the value or nil

Takes a value and wraps it in a tuple with the specified atom as the first item

Functions

@spec cont(term()) :: {:cont, term()}

Takes a value and wraps it in a :cont tuple

Examples

iex> Flamel.Wrap.cont([])
{:cont, []}

iex> Flamel.Wrap.cont("message")
{:cont, "message"}
@spec continue(term()) :: {:continue, term()}

Takes a value and wraps it in a :continue tuple

Examples

iex> Flamel.Wrap.continue(:load_something)
{:continue, :load_something}

iex> Flamel.Wrap.continue("message")
{:continue, "message"}
@spec error(term()) :: {:error, term()}

Takes a value and wraps it in a :error tuple

Examples

iex> Flamel.Wrap.error([])
{:error, []}

iex> Flamel.Wrap.error("message")
{:error, "message"}
@spec noreply(term()) :: {:noreply, term()}

Takes a value and wraps it in a :noreply tuple

Examples

iex> Flamel.Wrap.noreply([])
{:noreply, []}

iex> Flamel.Wrap.noreply("message")
{:noreply, "message"}
@spec ok(term()) :: {:ok, term()}

Takes a value and wraps it in a :ok tuple

Examples

iex> Flamel.Wrap.ok([])
{:ok, []}

iex> Flamel.Wrap.ok("message")
{:ok, "message"}

Takes an {:ok, value} or {:error, message} tuple and returns the value

Examples

iex> Flamel.Wrap.unwrap({:ok, []})
[]

iex> Flamel.Wrap.unwrap({:error, "message"})
"message"

Takes an {:ok, value} tuple and returns the value

Examples

iex> Flamel.Wrap.unwrap_error!({:ok, []})
** (ArgumentError) {:ok, []} is not an :error tuple

iex> Flamel.Wrap.unwrap_error!({:error, "message"})
"message"
Link to this function

unwrap_error_or_nil(arg1)

View Source

Takes an {:error, value} tuple and returns the value or nil

Examples

iex> Flamel.Wrap.unwrap_error_or_nil({:ok, []})
nil

iex> Flamel.Wrap.unwrap_error_or_nil({:error, "message"})
"message"

Takes an {:ok, value} tuple and returns the value

Examples

iex> Flamel.Wrap.unwrap_ok!({:ok, []})
[]

iex> Flamel.Wrap.unwrap_ok!({:error, "message"})
** (ArgumentError) {:error, "message"} is not an :ok tuple

Takes an {:ok, value} tuple and returns the value or nil

Examples

iex> Flamel.Wrap.unwrap_ok_or_nil({:ok, []})
[]

iex> Flamel.Wrap.unwrap_ok_or_nil({:error, "message"})
nil
@spec wrap(atom(), term()) :: {atom(), term()}

Takes a value and wraps it in a tuple with the specified atom as the first item

Examples

iex> Flamel.Wrap.wrap(:ok, [])
{:ok, []}

iex> Flamel.Wrap.wrap(:error, "message")
{:error, "message"}