diff options
author | rinpatch <rinpatch@sdf.org> | 2019-12-08 17:37:16 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-12-08 19:05:04 +0300 |
commit | 6ea40564c2aa2e58886fe929859df47a73b51377 (patch) | |
tree | 360a1a6e0f64b6269e21e9a50deeef0c89539608 /lib/pleroma/config.ex | |
parent | c9f881b75fb683c07822c6eacecd98635c5e6554 (diff) | |
download | pleroma-feature/compile_get.tar.gz |
Config: add compile_get!feature/compile_get
It utilizes
[`Application.compile_env!`](https://github.com/elixir-lang/elixir/pull/9628)
to crash the application when compile-time configuration is attempted to
be set at runtime. If `Application.compile_env!` is not available it just falls back to
regular `Pleroma.Config.get``
Diffstat (limited to 'lib/pleroma/config.ex')
-rw-r--r-- | lib/pleroma/config.ex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/pleroma/config.ex b/lib/pleroma/config.ex index fcc039710..ce98c7ae3 100644 --- a/lib/pleroma/config.ex +++ b/lib/pleroma/config.ex @@ -34,6 +34,18 @@ defmodule Pleroma.Config do end end + defmacro compile_get!(key) do + if function_exported?(Application, :__compile_env__!, 3) do + quote do + Application.compile_env!(:pleroma, unquote(key)) + end + else + quote do + get(unquote(key)) + end + end + end + def put([key], value), do: put(key, value) def put([parent_key | keys], value) do |