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

Link to this function

application_module(namespace \\ nil, type \\ :run) View Source
application_module(
  namespace :: atom(),
  type :: :run | :reload | :system | :config
) :: {:ok, term()} | {:error, term()}

Changes Application for a custom module (only for testing purposes).

A call to Skogsra.Settings.application_module() will:

  1. If the OS environment variable is not nil, will return its casted value.
  2. If the OS environment variable is nil, then it will try to get the value in the configuration file.
  3. If the configuration file does not contain the value, will return the default value if it's defined.
  4. 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().

Link to this function

application_module!(namespace \\ nil) View Source
application_module!(namespace :: atom()) :: term() | no_return()

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.

Link to this function

system_module(namespace \\ nil, type \\ :run) View Source
system_module(namespace :: atom(), type :: :run | :reload | :system | :config) ::
  {:ok, term()} | {:error, term()}

Changes System for a custom module (only for testing purposes).

A call to Skogsra.Settings.system_module() will:

  1. If the OS environment variable is not nil, will return its casted value.
  2. If the OS environment variable is nil, then it will try to get the value in the configuration file.
  3. If the configuration file does not contain the value, will return the default value if it's defined.
  4. 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().

Link to this function

system_module!(namespace \\ nil) View Source
system_module!(namespace :: atom()) :: term() | no_return()

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.