Dynamic Embeds in Ecto

@lukaszsamson two things

  1. I think that the Ecto.Type.embedded_dump and Ecto.Type.embedded_load in those Enum.reduce_while are 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?

  2. 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.