plexy v0.3.3 Plexy.Config
Provides access to a hard coded config value, a value stored as a environment variable on the current system at runtime or a default provided value.
The config.exs can look like this
config :plexy,
redis_url: {:system, "REDIS_URL"},
port: {:system, "PORT", 5000},
normal: "normal"
When using this modules get/3
function, System.get_env("REDIS_URL") will be
ran at runtime.
Link to this section Summary
Functions
Used to gain access to the application env. ## Examples
Like get/3
except it attempts to convert the value to an bool.
## Examples
iex> Plexy.Config.get_bool(:my_config, :bar, "true")
true
iex> Plexy.Config.get_bool(:my_config, :bar, "yes")
true
iex> Plexy.Config.get_bool(:my_config, :foo, "0")
false
iex> Plexy.Config.get_bool(:my_config, :baz, "no")
false
iex> Plexy.Config.get_bool(:my_config, :baz, "false")
false
iex> Plexy.Config.get_bool(:my_config, :baz, nil)
false
Like get/3
except it attempts to convert the value to an integer.
## Examples
iex> Application.put_env(:my_config, :port, "5000")
iex> Plexy.Config.get_int(:my_config, :port, 9999)
5000
iex> Plexy.Config.get_int(:my_config, :foo, "123")
123
Link to this section Functions
Link to this function
get(config_name, key, default \\ nil)
Used to gain access to the application env. ## Examples
iex> Application.put_env(:my_config, HerokuApi, heroku_api_url: "https://api.heroku.com")
iex> Plexy.Config.get(:my_config, {HerokuApi, :heroku_api_url})
"https://api.heroku.com"
iex> Plexy.Config.get(:my_config, {HerokuApi, :not_set}, "and a default")
"and a default"
iex> Application.put_env(:my_config, :redis_url, "redis://localhost:6379")
iex> Plexy.Config.get(:my_config, :redis_url)
"redis://localhost:6379"
iex> Plexy.Config.get(:my_config, :foo, "and a default")
"and a default"
Link to this function
get_bool(config_name, key, default \\ nil)
Like get/3
except it attempts to convert the value to an bool.
## Examples
iex> Plexy.Config.get_bool(:my_config, :bar, "true")
true
iex> Plexy.Config.get_bool(:my_config, :bar, "yes")
true
iex> Plexy.Config.get_bool(:my_config, :foo, "0")
false
iex> Plexy.Config.get_bool(:my_config, :baz, "no")
false
iex> Plexy.Config.get_bool(:my_config, :baz, "false")
false
iex> Plexy.Config.get_bool(:my_config, :baz, nil)
false
Link to this function
get_int(config_name, key, default \\ nil)
Like get/3
except it attempts to convert the value to an integer.
## Examples
iex> Application.put_env(:my_config, :port, "5000")
iex> Plexy.Config.get_int(:my_config, :port, 9999)
5000
iex> Plexy.Config.get_int(:my_config, :foo, "123")
123