return_helpers v0.1.1 ReturnHelpers

Simple library that adds a piping possibility for easy returning

Imagine

  socket =
    socket
    |> assign(valid: true)
  {:noreply, socket}

to write like:

  socket
  |> assign(valid: true)
  |> noreply()

Looks cleaner ?

Link to this section Summary

Functions

Example

iex> "34" |> ReturnHelpers.between_strings("12", "56") "123456"

Examples

iex> %{} |> error()
{:error, %{}}

Examples

iex> %{} |> noreply()
{:noreply, %{}}
iex> %{} |> noreply("state")
{:noreply, %{}, "state"}
iex> %{} |> noreply("state", [])
{:noreply, %{}, "state", []}

Examples

iex(3)> %{} |> ok()
{:ok, %{}}
iex(4)> %{} |> ok("params")
{:ok, %{}, "params"}

Examples

iex> %{} |> reply()
{:reply, %{}}
iex> %{} |> reply("state")
{:reply, %{}, "state"}
iex> %{} |> reply("state", [])
{:reply, %{}, "state", []}

Examples

iex> %{} |> stop()
{:stop, %{}}
iex> %{} |> stop("state")
{:stop, %{}, "state"}
iex> %{} |> stop("state", [])
{:stop, %{}, "state", []}

Examples

iex> %{} |> to_tuple(:ok) {:ok, %{}} iex> %{} |> to_tuple(:error, "params") {:error, %{}, "params"}

Link to this section Functions

Link to this function

between_strings(piped, string1, string2)

Example

iex> "34" |> ReturnHelpers.between_strings("12", "56") "123456"

Examples

iex> %{} |> error()
{:error, %{}}

Examples

iex> %{} |> noreply()
{:noreply, %{}}
iex> %{} |> noreply("state")
{:noreply, %{}, "state"}
iex> %{} |> noreply("state", [])
{:noreply, %{}, "state", []}
Link to this function

noreply(state, params)

Link to this function

noreply(state, params, other)

Examples

iex(3)> %{} |> ok()
{:ok, %{}}
iex(4)> %{} |> ok("params")
{:ok, %{}, "params"}
Link to this function

ok(return, params)

Examples

iex> %{} |> reply()
{:reply, %{}}
iex> %{} |> reply("state")
{:reply, %{}, "state"}
iex> %{} |> reply("state", [])
{:reply, %{}, "state", []}
Link to this function

reply(reply, state)

Link to this function

reply(reply, state, other)

Examples

iex> %{} |> stop()
{:stop, %{}}
iex> %{} |> stop("state")
{:stop, %{}, "state"}
iex> %{} |> stop("state", [])
{:stop, %{}, "state", []}
Link to this function

stop(reason, state)

Link to this function

stop(reason, reply, state)

Link to this function

to_tuple(piped, first_arg)

Examples

iex> %{} |> to_tuple(:ok) {:ok, %{}} iex> %{} |> to_tuple(:error, "params") {:error, %{}, "params"}

Link to this function

to_tuple(piped, first_arg, second_arg)