PostgresDescribe v0.1.4 PostgresDescribe.Config View Source

This module handles fetching values from the config with some additional niceties. Sourced from https://gist.github.com/bitwalker/a4f73b33aea43951fe19b242d06da7b9

MIT license as per author.

Link to this section Summary

Functions

Fetches a value from the config, or from the environment if {:system, “VAR”} is provided

Fetches a value from the config, or from the environment if {:system, “VAR”} is provided

Same as get/3, but returns the result as an integer. If the value cannot be converted to an integer, the default is returned instead

Link to this section Functions

Link to this function get(app, key, default \\ nil) View Source
get(atom(), atom(), term() | nil) :: term()

Fetches a value from the config, or from the environment if {:system, “VAR”} is provided.

An optional default value can be provided if desired.

Example

iex> {test_var, expected_value} = System.get_env |> Enum.take(1) |> List.first
...> Application.put_env(:myapp, :test_var, {:system, test_var})
...> ^expected_value = Elixir.PostgresDescribe.Config.get(:myapp, :test_var)
...> :ok
:ok

iex> Application.put_env(:myapp, :test_var2, 1)
...> 1 = Elixir.PostgresDescribe.Config.get(:myapp, :test_var2)
1

iex> :default = Elixir.PostgresDescribe.Config.get(:myapp, :missing_var, :default)
:default
Link to this function get!(app, key) View Source
get!(atom(), atom()) :: term() | no_return()

Fetches a value from the config, or from the environment if {:system, “VAR”} is provided.

If the environment variable is not set and no preconfigured default is provided it will raise an ArgumentError.

Link to this function get_integer(app, key, default \\ nil) View Source
get_integer(atom(), atom(), integer()) :: integer()

Same as get/3, but returns the result as an integer. If the value cannot be converted to an integer, the default is returned instead.