cover/Elixir.Agent.Config.html

1 defmodule Agent.Config do
2 import Enum, only: [map: 2, reject: 2]
3 import String, only: [to_atom: 1, split: 3, trim: 1]
4 import Application, only: [get_env: 2]
5
6 def load do
7 get_env(:elita, :registrations)
8 34 |> fetch()
9 end
10
11 1 defp fetch(nil), do: []
12 33 defp fetch(value), do: parse(value)
13
14 defp parse(value) do
15 value
16 |> split(",", [])
17 |> map(&item/1)
18 33 |> reject(&is_nil/1)
19 end
20
21 defp item(entry) do
22 entry
23 |> split(":", parts: 2)
24 132 |> build()
25 end
26
27 132 defp build([name, folder]) do
28 {to_atom(trim(name)), trim(folder)}
29 end
30
31
:-(
defp build(_), do: nil
32 end
Line Hits Source