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: https://github.com/nobrick/exaop/
Hex: https://hexdocs.pm/exaop/api-reference.html
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 Libraries
It is a well-know topic within the Elixir community: “To mock or not to mock? :)”
Every alchemist probably has his / her own opinion con...
New
Hi everyone,
I’m coming from the Symfony (PHP) framework. I like Phoenix, but it has a one thing that was build much better in the Symfo...
New
Another small library today.
PersistentEts
Hex: persistent_ets | Hex
GitHub: GitHub - michalmuskala/persistent_ets
Ets table backed by...
New
Hello everybody.
I have just released Jason - a new JSON library.
You might be wondering, why do we need a new library? The primary foc...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
PhoenixWS - Websockets over Phoenix Channels
Source code on Github here: https://github.com/tmbb/phoenix_ws
Phoenix channels are a great...
New
Hi everyone!
I’m thrilled to announce a huge thing. We have been developing Elixir Moon Design System for quite a while. We are finally ...
New
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode.
The solution seems to be, in a hyphena...
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
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







