Current section

Files

Jump to
mpx lib mpx mpx_config.ex
Raw

lib/mpx/mpx_config.ex

defmodule Mpx.Config do
@moduledoc """
Catch all module to hold config functions
"""
@doc """
Given the result of the configuration, convert it to the actual value.
It mainly exists to support `{:system, ENV_VAR}` values.
"""
@spec from_config(atom(), term() | nil) :: no_return | String.t
def from_config(config_param, nil), do: raise "#{config_param} is a required configuration parameter"
def from_config(config_param, {:system, env_var}), do: from_config(config_param, System.get_env(env_var))
def from_config(_config_param, any_val), do: any_val
end