Small wrapper module around Application.get_env/put_env

Same API as the old Pleroma.Config
This commit is contained in:
href 2018-11-06 16:00:48 +01:00
commit 7d328c658d
No known key found for this signature in database
GPG key ID: EE8296C1A152C325
4 changed files with 69 additions and 20 deletions

26
lib/pleroma/config.ex Normal file
View file

@ -0,0 +1,26 @@
defmodule Pleroma.Config do
def get([key]), do: get(key)
def get([parent_key | keys]) do
Application.get_env(:pleroma, parent_key)
|> get_in(keys)
end
def get(key) do
Application.get_env(:pleroma, key)
end
def put([key], value), do: put(key, value)
def put([parent_key | keys], value) do
parent =
Application.get_env(:pleroma, parent_key)
|> put_in(keys, value)
Application.put_env(:pleroma, parent_key, parent)
end
def put(key, value) do
Application.put_env(:pleroma, key, value)
end
end