View Source Flamel.Wrap (flamel v1.10.0)
Some helper functions for wrapping and unwraping values in tuples
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 a value and wraps it in a :reply tuple
Takes a value and wraps it in a :stop tuple
Takes an {:ok, value} or {:error, message} tuple and returns the value
Takes a value and wraps it in a tuple with the specified atom as the first item
Functions
Takes a value and wraps it in a :cont tuple
Examples
iex> Flamel.Wrap.cont([])
{:cont, []}
iex> Flamel.Wrap.cont("message")
{:cont, "message"}
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"}
iex> Flamel.Wrap.continue(:first, :second)
{:continue, :first, :second}
Takes a value and wraps it in a :error tuple
Examples
iex> Flamel.Wrap.error([])
{:error, []}
iex> Flamel.Wrap.error("message")
{:error, "message"}
iex> Flamel.Wrap.error(:first, :second)
{:error, :first, :second}
Takes a value and wraps it in a :noreply tuple
Examples
iex> Flamel.Wrap.noreply([])
{:noreply, []}
iex> Flamel.Wrap.noreply("message")
{:noreply, "message"}
iex> Flamel.Wrap.noreply(:first, :second)
{:noreply, :first, :second}
Takes a value and wraps it in a :ok tuple
Examples
iex> Flamel.Wrap.ok([])
{:ok, []}
iex> Flamel.Wrap.ok("message")
{:ok, "message"}
See Flamel.Result.ok?/1
.
Takes a value and wraps it in a :reply tuple
Examples
iex> Flamel.Wrap.reply([])
{:reply, []}
iex> Flamel.Wrap.reply("message")
{:reply, "message"}
iex> Flamel.Wrap.reply(:first, :second)
{:reply, :first, :second}
Takes a value and wraps it in a :stop tuple
Examples
iex> Flamel.Wrap.stop(:shutdown, %{})
{:stop, :shutdown, %{}}
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"
See Flamel.Result.ok!/1
.
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"}
iex> Flamel.Wrap.wrap(:stop, :shutdown, %{})
{:stop, :shutdown, %{}}