Function Decorating v0.0.3 FunctionDecorating
Add a function decorating availability to a module.
Usage
Decorating in dev with log decorator.
defmodule User do
use FunctionDecorating
decorate_fn_with(LogDecorator)
def say(word) do
word
end
end
iex >User.say("hello")
#PID<0.86.0> [x] Elixir.User.say(["hello"]) -> "hello"
"hello"
Default usage is for Mix.env == :dev only. To override it:
defmodule User do
use FunctionDecorating mix_envs: [:prod]
decorate_fn_with(LogDecorator)
def say(word) do
word
end
end
iex >Mix.env
:prod
iex >User.say("hello")
#PID<0.86.0> [x] Elixir.User.say(["hello"]) -> "hello"
"hello"
Summary
Macros
The decorator mechanism. Override the original Kernel.def by not inlucing it in the import statement