Skip to content

Commit

Permalink
Allow string and atom keys in Estructura.Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Feb 13, 2024
1 parent 4faeb7e commit 6417b52
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/estructura/tree.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ defmodule Estructura.Tree do
|> Map.split(~w|name attributes content| ++ ~w|name attributes content|a)
|> case do
{map, empty} when %{} == empty ->
Map.new(map, fn {k, v} -> {String.to_existing_atom(k), v} end)
Map.new(map, fn
{k, v} when is_binary(k) -> {String.to_existing_atom(k), v}
{k, v} when is_atom(k) -> {k, v}
end)

{_, non_empty} ->
keys = non_empty |> Map.keys() |> Enum.map(&Enum.join(key_prefix ++ [&1], "."))
Expand Down

0 comments on commit 6417b52

Please sign in to comment.