Skip to content

Commit d23010e

Browse files
Check otp_app on compile time in Avrora.Client (#129)
--------- Co-authored-by: Sergey Fedorov <oni.strech@gmail.com>
1 parent 71be139 commit d23010e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/avrora/client.ex

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,6 @@ defmodule Avrora.Client do
103103
@opts unquote(opts)
104104
@otp_app Keyword.get(@opts, :otp_app)
105105

106-
def schemas_path do
107-
path = get(@opts, :schemas_path, "./priv/schemas")
108-
109-
if is_nil(@otp_app), do: Path.expand(path), else: Application.app_dir(@otp_app, path)
110-
end
111-
112-
def registry_ssl_cacert_path do
113-
path = get(@opts, :registry_ssl_cacert_path, nil)
114-
115-
if is_nil(path), do: nil, else: Path.expand(path)
116-
end
117-
118106
def registry_url, do: get(@opts, :registry_url, nil)
119107
def registry_auth, do: get(@opts, :registry_auth, nil)
120108
def registry_user_agent, do: get(@opts, :registry_user_agent, "Avrora/#{version()} Elixir")
@@ -134,10 +122,14 @@ defmodule Avrora.Client do
134122

135123
if is_nil(@otp_app) do
136124
def self, do: __MODULE__
125+
def schemas_path, do: Path.expand(get(@opts, :schemas_path, "./priv/schemas"))
126+
def registry_ssl_cacert_path, do: nil
137127

138128
defp get(opts, key, default), do: Keyword.get(opts, key, default)
139129
else
140130
def self, do: get(@opts, :config, __MODULE__)
131+
def schemas_path, do: Application.app_dir(@otp_app, get(@opts, :schemas_path, "./priv/schemas"))
132+
def registry_ssl_cacert_path, do: Path.expand(get(@opts, :registry_ssl_cacert_path, nil))
141133

142134
defp get(opts, key, default) do
143135
app_opts = Application.get_env(@otp_app, unquote(:"Elixir.#{module}"), [])

0 commit comments

Comments
 (0)