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 ![]()
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.
Popular in Announcing
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
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...
New
Hey all,
We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3!
We have successfully on-boarded the full suite of integration tests (...
New
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
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
Ash Framework
What is Ash?
Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
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
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
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
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
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...
New
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...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









