husky v0.2.0 Constants View Source

An alternative to use @constant_name value approach to defined reusable constants in elixir. This module offers an approach to define these in a module that can be shared with other modules. They are implemented with macros so they can be used in guards and matches

Examples:

Create a module to define your shared constants

defmodule MyConstants do
  use Constants
  define something,   10
  define another,     20
end

Use the constants

defmodule MyModule do
  require MyConstants
  alias MyConstants, as: Const
  def myfunc(item) when item == Const.something, do: Const.something + 5
  def myfunc(item) when item == Const.another, do: Const.another
end

Link to this section Summary

Functions

Define a constant

Define a constant. An alias for constant

Link to this section Functions

Link to this macro constant(name, value) View Source (macro)

Define a constant

Link to this macro define(name, value) View Source (macro)

Define a constant. An alias for constant