Created
July 18, 2024 15:29
-
-
Save YannickFricke/fe1f9afde8125fe07168be8a186a4f55 to your computer and use it in GitHub Desktop.
Phoenix Utility methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Utils do | |
@moduledoc """ | |
## Usage | |
Could be imported in <project>/lib/my_app_web.ex for general access. | |
For example in controller/0 | |
```elixir | |
import Utils | |
def fancy_function() do | |
"input" | |
|> String.split("") | |
|> Enum.join() | |
|> noreply() | |
end | |
``` | |
""" | |
@spec ok(value :: term()) :: {:ok, term()} | |
def ok(value), do: {:ok, value} | |
@spec error(value :: term()) :: {:error, term()} | |
def error(value), do: {:error, value} | |
@spec noreply(value :: term()) :: {:noreply, term()} | |
def noreply(value), do: {:noreply, value} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment