I’m developing a form library. It now requires Ecto and I want to extract that Ecto stuff into another library. I want to write a core lib in such a way that it don’t know about existence of that new Ecto extension library.
Currently this is the only way I can create a form:
create_form(ArticleType, %Article{}, params)
where Article
is an Ecto schema.
I think it would be nice if in a new version I could use it like that
create_form(ArticleType, %SomeStructNotSchema{}, params)
- a normal struct, handled by core libcreate_form(ArticleType, %{}, params)
- a map, handled by core libcreate_form(ArticleType, %Article{}, params)
- Ecto schema, handled by new Ecto lib
but I’m afraid it’s impossible
Of course I know that I could create different functions, like Formex.Ecto.create_form
, Formex.Something.create_form
… but I’m curious if it is possible to avoid that.