projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Runtime config: MRF changes
[akkoma]
/
lib
/
pleroma
/
config.ex
diff --git
a/lib/pleroma/config.ex
b/lib/pleroma/config.ex
index fc5338591d684b9da364644d99a33cfc84dc0155..15f771b6e29c2803a807d3138e36740e949088f2 100644
(file)
--- a/
lib/pleroma/config.ex
+++ b/
lib/pleroma/config.ex
@@
-1,13
+1,29
@@
defmodule Pleroma.Config do
defmodule Pleroma.Config do
- def get([key]), do: get(key)
+ defmodule Error do
+ defexception [:message]
+ end
+
+ def get(key), do: get(key, nil)
+
+ def get([key], default), do: get(key, default)
- def get([parent_key | keys]) do
+ def get([parent_key | keys]
, default
) do
Application.get_env(:pleroma, parent_key)
Application.get_env(:pleroma, parent_key)
- |> get_in(keys)
+ |> get_in(keys)
|| default
end
end
- def get(key) do
- Application.get_env(:pleroma, key)
+ def get(key, default) do
+ Application.get_env(:pleroma, key, default)
+ end
+
+ def get!(key) do
+ value = get(key, nil)
+
+ if value == nil do
+ raise(Error, message: "Missing configuration value: #{inspect(key)}")
+ else
+ value
+ end
end
def put([key], value), do: put(key, value)
end
def put([key], value), do: put(key, value)