nobrick

nobrick

Exaop - a minimal library for aspect-oriented programming

Exaop is a minimal library for aspect-oriented programming.

In most cases, you may not need to use AOP pattern. But for some specific complex application workflows, hope it helps :slight_smile:

GitHub: GitHub - nobrick/exaop: A minimal elixir library for aspect-oriented programming. · GitHub
Hex: API Reference — Exaop v0.1.0

Example:

defmodule Wallet do
  use Exaop
  require Logger

  # Decouple cross-cutting concerns to make workflows simple and self-documenting.
  set :config, [:max_allowed_amount, :fee_rate]
  set :accounts

  check :amount, guard: :positive
  check :amount, guard: {:lt_or_eq, :max_allowed_amount}
  check :recipient, :not_equal_to_sender
  check Wallet.AML

  set :fee
  check :balance

  # A function injected by explicitly calling __inject__/2 generated by Exaop.
  def transfer(%{from: _, to: _, amount: _} = payload) do
    info
    |> __inject__(%{})
    |> handle_inject(payload)
  end

  defp handle_inject({:error, _} = error, _payload) do
    error
  end

  defp handle_inject(_acc, _payload) do
    Wallet.Core.transfer!(acc, payload)
  end

  # Then implement your callbacks required by the macros, eg. check_amount/3.
  # View the full code snippet in GitHub for details.
end

All suggestion, criticism and feedback are welcome.

Where Next?

Popular in Announcing Top

Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 12978 134
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
brainlid
LangChain is short for Language Chain. An LLM, or Large Language Model, is the “Language” part. This library makes it easier for Elixir a...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement