Oriza

A way to add contexts to function calls. Given:

defmodule MyModule do
  use Oriza.Context

  @context admin: [:read, :write]
  def do_something(arg), do: arg
end

Creates the following additional function definition:

def do_something(context, arg) do
  with :ok <- check_context(context) do
    do_something(arg)
  else
    _ -> {:error, "access denied"}
end

Installation

If available in Hex, the package can be installed by adding oriza to your list of dependencies in mix.exs:

def deps do
  [
    {:oriza, "~> 0.0.1"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/oriza.