if_ok is a small utility library that let's you create pipelines that expect ok tuples to continue in a very readable way.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config initial commit Sep 30, 2016
lib add tests Sep 30, 2016
test add tests Sep 30, 2016
.gitignore initial commit Sep 30, 2016
README.md update docs Sep 30, 2016
mix.exs bump version number Sep 30, 2016
mix.lock add tests Sep 30, 2016

README.md

if_ok

if_ok if_ok is a small utility library that let's you create pipelines that expect ok tuples to continue in a very readable way.

An example how we can use this:

defmodule MyApp.DoStuff do
  import IfOk
  alias MyApp.Repo

  def broadcast_out(item) do: {:ok, item}
  def update(changeset, user) do
    changeset
    |> authorize(user, :update)
    |> if_ok(&Repo.update)
    |> if_ok(&broadcast_out)
    |> if_ok(:ok)
  end
end

Installation

The package can be installed as:

  1. Add if_ok to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:if_ok, "~> 0.1.0"}]
end
```
  1. Ensure if_ok is started before your application:
```elixir
def application do
  [applications: [:if_ok]]
end
```