<a href="" target="_blank"><img src=""/></a>

# erl-decorator-pt

Transformations in Erlang syntax allowing cache decorator directives above functions to cache them
using [erl-cache](

This is a fork of [spilgames/erl-decorator-pt]( for [Alert Logic](


This application implements a set of transformations in the erlang syntax tree allowing the

* The *decorator* directive on top of functions in order to add extra functionality to them

* The *?FUNCTION* and *?ARITY* macros, returning an atom with the function name corresponding to the
  current scope and the amount of arguments that function was invoked with. These macros can be used
  in your decorators.


There are many ways to include these macros in your projects. Just remember macros and macro
debugging in particular are not the simplest tools in the world. _A great power comes with a great

The most common way of using this application is:

1. Make it available to your application via rebar

2. Create an .hrl file loading hooking the decorator_pt_core in the compilation process and defining
   a macro with a representative name for your decorator. i.e. my_decorator.hrl

-compile([{parse_transform, decorator_pt_core}]).

-define(MY_DECORATOR(Options), -decorate({MyCbModule, MyCbFun, {?MODULE, ?FUNCTION, Options}})).


3. Define the callback function in the callback module to your liking. Keep in mind what the
   signature of your callback should be:

my_cb_fun(OriginalFun::function(), Args::[tern()],
          {OriginalModule::atom(), OriginalFunctionName::atom(), Opts::[term()]) ->
    FunReturningResult::fun(() -> term()).

4. When using your decorator, include *my_decorator.hrl* and *decorator_pt.hrl* in that order.



?MY_DECORATOR([{opt1, val}]).
my_decorated_fun() ->