Use LastFm.Config where needed

This commit is contained in:
Claudio Ortolina
2024-12-03 09:18:55 +00:00
parent b49434b789
commit 2094c1cf7b
6 changed files with 36 additions and 34 deletions
+11
View File
@@ -15,4 +15,15 @@ defmodule LastFm.Config do
def new(opts) do
struct(__MODULE__, opts)
end
@spec enabled?(t) :: boolean()
def enabled?(config) do
config.api && config.user !== "" && config.api_key !== ""
end
def resolve(otp_app) do
otp_app
|> Application.get_env(LastFm)
|> new()
end
end