Arke.Hook.DSL (Arke v0.9.0-rc.3)

Copy Markdown View Source

Plug-style hook registration, available inside use Arke.System and use Arke.System.Group modules.

before_write :check_cashback_limit, on: :create
after_commit :send_status_email,    on: [:create, :update]
after_write fn hook -> {:ok, hook} end

Handlers are private arity-1 functions named by atom, or captures/anonymous functions for one-liners. Registration order is execution order; multiple hooks per slot are first-class. on: filters by operation (:create | :update | :delete); without it the hook runs on every op.

At @before_compile the accumulated registrations become __arke_hooks__/0 (the ordered entry list Arke.Hook.Pipeline reads) and __arke_hook_call__/2 (the dispatcher that reaches private handlers).

Summary

Functions

after_commit(handler, opts \\ [])

(macro)

after_rollback(handler, opts \\ [])

(macro)

after_write(handler, opts \\ [])

(macro)

before_transaction(handler, opts \\ [])

(macro)

before_write(handler, opts \\ [])

(macro)