Compile-Time Hooks
Learn to fix the test macro using compile-time hooks.
We'll cover the following...
The before_compile
module attribute
Elixir allows us to set a special module attribute, @before_compile
, to notify the compiler that an extra step is required just before compilation is finished. The @before_compile
attribute accepts a module argument where a __before_com- pile__/1
macro must be defined. This macro is invoked just before compilation to perform a final bit of code generation. Let’s apply this hook to fix our test
macro.
Using the before_compile
module attribute
Let’s update our Assertion
module with these @before_compile
...