defmodule Manganese.SerializationKit.Structs.UnityGameObject do @moduledoc """ """ alias Manganese.SerializationKit.Structs @typedoc """ """ @type t :: %Structs.UnityGameObject{ name: String.t, components: [ Structs.UnityComponent.t ], children: [ Structs.UnityGameObject.t ] } defstruct [ :name, :components, :children ] # Deserialization @doc """ """ @spec from_map(t_external) :: t def from_map(%{ "name" => name, "components" => components, "children" => children }) do %Structs.UnityGameObject{ name: name, components: components |> Enum.map(&Structs.UnityComponent.from_map/1), children: children |> Enum.map(&from_map/1) } end # Serialization @type t_external :: map @doc """ """ @spec to_map(t) :: t_external def to_map(%Structs.UnityGameObject{ name: name, components: components, children: children }) do %{ "name" => name, "components" => components |> Enum.map(&Structs.UnityComponent.to_map/1), "children" => children |> Enum.map(&to_map/1) } end end