View Source Kloak.Utils (kloak v0.1.0)

Utility module which offers some functionality for other modules.

Summary

Functions

Fetches and retruns a setting fetched under the given key or path. When the setting was not found under the given key/path, the given default value is returned. According to Application.compile_env/3 and Application.compile_env!/2 it's possible to provide a key or a path of keys to fetch a setting.

Fetches and retruns a setting fetched under the given key or path. When the setting was not found under the given key/path, an ArgumentError will be raised. According to Application.compile_env/3 and Application.compile_env!/2 it's possible to provide a key or a path of keys to fetch a setting.

Functions

Link to this function

fetch_env(app, key_or_path, default \\ nil)

View Source
@spec fetch_env(atom(), atom() | [atom()], any()) :: any()

Fetches and retruns a setting fetched under the given key or path. When the setting was not found under the given key/path, the given default value is returned. According to Application.compile_env/3 and Application.compile_env!/2 it's possible to provide a key or a path of keys to fetch a setting.

Examples

iex> fetch_env(:keymaster, [:key_1, :key_2, :key_3])
"value3"

iex> fetch_env(:keymaster, [:key_1, :key_2, :key_3], "default")
"default"

iex> fetch_env(:keymaster, :other_key)
"other_value"
Link to this function

fetch_env!(app, key_or_path)

View Source
@spec fetch_env!(atom(), atom() | [atom()]) :: any()

Fetches and retruns a setting fetched under the given key or path. When the setting was not found under the given key/path, an ArgumentError will be raised. According to Application.compile_env/3 and Application.compile_env!/2 it's possible to provide a key or a path of keys to fetch a setting.

Examples

iex> fetch_env!(:keymaster, [:key_1, :key_2, :key_3])
"value3"

iex> fetch_env!(:keymaster, [:key_1, :key_2, :key_3])
ArgumentError

iex> fetch_env(:keymaster, :other_key)
"other_value"