@lukaszsamson two things
-
I think that the
Ecto.Type.embedded_dumpandEcto.Type.embedded_loadin thoseEnum.reduce_whileare unnecessary, and that represents a lot of code in your Ecto type.
Because you know the schema based on the ‘type’ field (def load(%{@type_field => module_string} = data)), so when loading the data from the DB, you can simply cast those values against the changeset of your schema. And the cast will convert the data to the right elixir data. Or did I miss something? -
I don’t understand why you say off-topic as the library above for example does exactly what you are doing, i.e. picking dynamically an embedded struct based on some ‘type’ field, and store it in some field.






















