zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

commit 1f9cb2dee53b5b93b98e79c5814579ebe65e2b7f
parent ddb116a76ef9396a78e8293c3c427ca6dea58298
Author: srfsh <dev@srf.sh>
Date:   Tue, 15 Nov 2022 00:51:12 +0300

Zenflows.VF.Action: tiny fix when preloading

When the key doesn't exist, we preload it to nil.

Diffstat:
Msrc/zenflows/vf/action.ex | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/zenflows/vf/action.ex b/src/zenflows/vf/action.ex @@ -42,11 +42,9 @@ embedded_schema do end @doc "Preloads the Action struct by the given `key`." -@spec preload(Ecto.Schema.t(), atom()) :: Ecto.Schema.t() +@spec preload(Ecto.Schema.t(), atom()) :: nil | Ecto.Schema.t() def preload(schema, key) do - key_id = String.to_existing_atom("#{key}_id") - action = Map.fetch!(map(), Map.fetch!(schema, key_id)) - %{schema | key => action} + %{schema | key => Map.get(map(), Map.fetch!(schema, :"#{key}_id"))} end @doc """