Skogsrå v1.2.0 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)

Puts the value to Skogsra.Settings.application_module/0. Optionally, receives the namespace

Puts the value to Skogsra.Settings.system_module/0. Optionally, receives the namespace

Reloads the value for Skogsra.Settings.application_module/0. Optionally, receives the namespace for the variable

Reloads the value for Skogsra.Settings.system_module/0. Optionally, receives the namespace for the variable

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) View Source
application_module(Skogsra.Env.namespace()) :: {:ok, term()} | {:error, term()}

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

A call to Skogsra.Settings.application_module():

  1. When the OS environment variable is not nil, then it'll return its casted value.
  2. When the OS environment variable is nil, then it'll try to get the value from the configuration file.
  3. When the configuration file does not contain the variable, then it'll return the default value if it's defined.
  4. When the default value is not defined and it's not required, it'll return nil, otherwise it'll return an error.

A call to Skogsra.Settings.application_module(namespace) will try to do the same as before, but with a namespace (atom()). This is useful for spliting different configurations values for the same variable e.g. different environments.

The OS environment variables expected are:

  • When no namespace is specified, then it'll be $SKOGSRA_APPLICATION_MODULE.
  • When a namespace is specified e.g. My.Custom.Namespace, then it'll be $MY_CUSTOM_NAMESPACE_SKOGSRA_APPLICATION_MODULE.

The expected application configuration would be as follows:

  • Without namespace:
  config :skogsra,
  application_module: :atom() # Defaults to Application
  • With namespace e.g. My.Custom.Namespace:
  config :skogsra, My.Custom.Namespace,
  application_module: :atom() # Defaults to Application
Link to this function

application_module!(namespace \\ nil) View Source
application_module!(Skogsra.Env.namespace()) :: {:ok, term()} | {:error, term()}

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

Bang version of Skogsra.Settings.application_module/0 (fails on error).

Link to this function

put_application_module(value, namespace \\ nil) View Source
put_application_module(term(), Skogsra.Env.namespace()) ::
  :ok | {:error, term()}

Puts the value to Skogsra.Settings.application_module/0. Optionally, receives the namespace.

Link to this function

put_system_module(value, namespace \\ nil) View Source
put_system_module(term(), Skogsra.Env.namespace()) :: :ok | {:error, term()}

Puts the value to Skogsra.Settings.system_module/0. Optionally, receives the namespace.

Link to this function

reload_application_module(namespace \\ nil) View Source
reload_application_module(Skogsra.Env.namespace()) ::
  {:ok, term()} | {:error, term()}

Reloads the value for Skogsra.Settings.application_module/0. Optionally, receives the namespace for the variable.

Link to this function

reload_system_module(namespace \\ nil) View Source
reload_system_module(Skogsra.Env.namespace()) ::
  {:ok, term()} | {:error, term()}

Reloads the value for Skogsra.Settings.system_module/0. Optionally, receives the namespace for the variable.

Link to this function

system_module(namespace \\ nil) View Source
system_module(Skogsra.Env.namespace()) :: {:ok, term()} | {:error, term()}

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

A call to Skogsra.Settings.system_module():

  1. When the OS environment variable is not nil, then it'll return its casted value.
  2. When the OS environment variable is nil, then it'll try to get the value from the configuration file.
  3. When the configuration file does not contain the variable, then it'll return the default value if it's defined.
  4. When the default value is not defined and it's not required, it'll return nil, otherwise it'll return an error.

A call to Skogsra.Settings.system_module(namespace) will try to do the same as before, but with a namespace (atom()). This is useful for spliting different configurations values for the same variable e.g. different environments.

The OS environment variables expected are:

  • When no namespace is specified, then it'll be $SKOGSRA_SYSTEM_MODULE.
  • When a namespace is specified e.g. My.Custom.Namespace, then it'll be $MY_CUSTOM_NAMESPACE_SKOGSRA_SYSTEM_MODULE.

The expected application configuration would be as follows:

  • Without namespace:
  config :skogsra,
  system_module: :atom() # Defaults to System
  • With namespace e.g. My.Custom.Namespace:
  config :skogsra, My.Custom.Namespace,
  system_module: :atom() # Defaults to System
Link to this function

system_module!(namespace \\ nil) View Source
system_module!(Skogsra.Env.namespace()) :: {:ok, term()} | {:error, term()}

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

Bang version of Skogsra.Settings.system_module/0 (fails on error).