Skogsrå v1.1.1 Skogsra.Settings View Source
Settings for Skogsra (only testing purposes).
Link to this section Summary
Functions
Changes Application
for a custom module (only for testing purposes)
Changes Application
for a custom module (only for testing purposes)
Changes System
for a custom module (only for testing purposes)
Changes System
for a custom module (only for testing purposes)
Link to this section Functions
application_module(namespace \\ nil, type \\ :run) View Source
Changes Application
for a custom module (only for testing purposes).
A call to Skogsra.Settings.application_module()
will:
- If the OS environment variable is not
nil
, will return its casted value. - If the OS environment variable is
nil
, then it will try to get the value in the configuration file. - If the configuration file does not contain the value, will return the default value if it's defined.
- If the default value is not defined and is not required, it will
return
nil
, otherwise it will error.
A call to Skogsra.Settings.application_module(namespace)
will try
to do the same as before, but using a namespace (atom()
). This is
useful for separating the different configurations values for the same
variable.
The OS environment variable expected is
$SKOGSRA_APPLICATION_MODULE
. If there is a namespace, for
example Namespace
, the OS environment variable would be
$NAMESPACE_SKOGSRA_APPLICATION_MODULE
.
The expected application configuration is as follows:
config :skogsra,
application_module: atom() # Defaults to Application
and with a namespace, for example Namespace
, the expected application
configuration would be:
config :skogsra, Namespace,
application_module: atom() # Defaults to Application
For testing purposes, the value can be reloaded at runtime with the
function Skogsra.Settings.application_module(namespace, :reload)
where
namespace
can be nil
or an atom()
.
application_module!(namespace \\ nil) View Source
Changes Application
for a custom module (only for testing purposes).
Same as Skogsra.Settings.application_module/0
but fails on error.
It can receive also a namespace when needed.
system_module(namespace \\ nil, type \\ :run) View Source
Changes System
for a custom module (only for testing purposes).
A call to Skogsra.Settings.system_module()
will:
- If the OS environment variable is not
nil
, will return its casted value. - If the OS environment variable is
nil
, then it will try to get the value in the configuration file. - If the configuration file does not contain the value, will return the default value if it's defined.
- If the default value is not defined and is not required, it will
return
nil
, otherwise it will error.
A call to Skogsra.Settings.system_module(namespace)
will try
to do the same as before, but using a namespace (atom()
). This is
useful for separating the different configurations values for the same
variable.
The OS environment variable expected is
$SKOGSRA_SYSTEM_MODULE
. If there is a namespace, for
example Namespace
, the OS environment variable would be
$NAMESPACE_SKOGSRA_SYSTEM_MODULE
.
The expected application configuration is as follows:
config :skogsra,
system_module: atom() # Defaults to System
and with a namespace, for example Namespace
, the expected application
configuration would be:
config :skogsra, Namespace,
system_module: atom() # Defaults to System
For testing purposes, the value can be reloaded at runtime with the
function Skogsra.Settings.system_module(namespace, :reload)
where
namespace
can be nil
or an atom()
.
system_module!(namespace \\ nil) View Source
Changes System
for a custom module (only for testing purposes).
Same as Skogsra.Settings.system_module/0
but fails on error.
It can receive also a namespace when needed.