DefineConstants (DefineConstants v0.1.0) View Source
Elixir library to provide constants functionality.
Usage
DefineConstants provides the define
macro to create custom constants. Constants should live inside their own modules.
defmodule MyConstants do
use DefineConstants
define(:name, "MyApplication")
define(:number, 7)
end
The define
macro takes atom keys and arbitrary values. The provided key/value pairs are used to create the constant
macro.
Caller functions use the constant
macro to retrieve the constant values.
defmodule Caller do
import MyConstants
constant(:name)
constant(:number) + 10
end
Since constant
is a macro, at compile time, all constant
calls are converted to their appropriate values.