Skip to content

Commit 07482cb

Browse files
committed
simplify even more...
1 parent b1d8e4e commit 07482cb

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

lib/atomic_map.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,15 @@ defmodule AtomicMap do
1111
def convert(map, opts) when is_map(map) do
1212
safe = Keyword.get(opts, :safe, true)
1313
map |> Enum.reduce(%{}, fn({k,v}, acc)->
14-
if is_binary(k), do: k = as_atom(k, safe)
15-
if is_complex?(v), do: v = convert(v, opts)
14+
k = as_atom(k, safe)
15+
v = convert(v, opts)
1616
acc |> Map.put(k, v)
1717
end)
1818
end
1919
def convert(list, opts) when is_list(list) do
2020
list |> Enum.map(fn(x)-> convert(x, opts) end)
2121
end
2222
def convert(v, _opts), do: v
23-
24-
defp is_complex?(v), do: is_map(v) || is_list(v)
2523
defp as_atom(s, true) when is_binary(s), do: s |> String.to_existing_atom
2624
defp as_atom(s, true), do: s
2725

0 commit comments

Comments
 (0)