Skip to content

Instantly share code, notes, and snippets.

View Electron-libre's full-sized avatar

Cedric Brancourt Electron-libre

View GitHub Profile
@Electron-libre
Electron-libre / conf_wrapper.ex
Last active January 23, 2018 10:15
elixir_config_wrapper.ex
defmodule Gifnoc.Config do
@spec get(atom, atom, term | nil) :: term
def get(app, key, default \\ nil) when is_atom(app) and is_atom(key) do
case read_config(Application.get_env(app, key)) do
nil -> default
val -> val
end
end
def read_config({:system, var_name}), do: System.get_env(var_name)