hivent v1.0.2 Hivent.Config
This module handles fetching values from the config with some additional niceties.
Summary
Functions
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} = System.get_env |> Enum.take(1) |> List.first
...> Application.put_env(:myapp, :test_var, {:system, test_var})
...> ^expected = Elixir.Hivent.Config.get(:myapp, :test_var)
...> :ok
:ok
iex> Application.put_env(:myapp, :test_var2, 1)
...> 1 = Elixir.Hivent.Config.get(:myapp, :test_var2)
1
iex> :default = Elixir.Hivent.Config.get(:myapp, :missing_var, :default)
:default
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
Functions
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} = System.get_env |> Enum.take(1) |> List.first
...> Application.put_env(:myapp, :test_var, {:system, test_var})
...> ^expected = Elixir.Hivent.Config.get(:myapp, :test_var)
...> :ok
:ok
iex> Application.put_env(:myapp, :test_var2, 1)
...> 1 = Elixir.Hivent.Config.get(:myapp, :test_var2)
1
iex> :default = Elixir.Hivent.Config.get(:myapp, :missing_var, :default)
:default