Using :eph from now on to store ephemeral data like :sibling_with. Additionally added cleaning up :eph before saving to db. And renamed InternalTree.Basic to InternalTree.RawInternalBasic to make clear that it contains function for an intermediary tree structure.
23 lines
540 B
Elixir
23 lines
540 B
Elixir
defmodule Outlook.InternalTree.Basic do
|
|
|
|
alias Outlook.InternalTree.InternalNode
|
|
alias Outlook.InternalTree.TranslationUnit
|
|
|
|
def clean_eph([%TranslationUnit{} = node | rest]) do
|
|
[ node | rest ]
|
|
end
|
|
|
|
def clean_eph([%InternalNode{type: :element} = node | rest]) do
|
|
[ %InternalNode{node |
|
|
eph: %{},
|
|
content: clean_eph(node.content)}
|
|
| clean_eph(rest) ]
|
|
end
|
|
|
|
def clean_eph([%{type: _} = node | rest]) do
|
|
[ %InternalNode{node | eph: %{}} | clean_eph(rest) ]
|
|
end
|
|
|
|
def clean_eph([]), do: []
|
|
end
|