Skip to content

Commit d233074

Browse files
committed
even less code ;)
1 parent cf4023b commit d233074

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

lib/atomic_map.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
defmodule AtomicMap do
2-
def convert(v, opts \\ [])
32

3+
def convert(v, opts \\ [])
44
def convert(struct=%{__struct__: type}, opts) do
55
struct
66
|> Map.from_struct
77
|> convert(opts)
88
|> Map.put(:__struct__, type)
99
end
10-
1110
def convert(map, opts) when is_map(map) do
1211
safe = Keyword.get(opts, :safe, true)
1312
map |> Enum.reduce(%{}, fn({k,v}, acc)->
@@ -23,9 +22,8 @@ defmodule AtomicMap do
2322
tuple |> Tuple.to_list |> convert(opts) |> List.to_tuple
2423
end
2524
def convert(v, _opts), do: v
26-
defp as_atom(s, true) when is_binary(s), do: s |> String.to_existing_atom
27-
defp as_atom(s, true), do: s
2825

26+
defp as_atom(s, true) when is_binary(s), do: s |> String.to_existing_atom
2927
defp as_atom(s, false) when is_binary(s), do: s |> String.to_atom
30-
defp as_atom(s, false), do: s
28+
defp as_atom(s, _), do: s
3129
end

0 commit comments

Comments
 (0)