Ecto has_one based on type

I stuck a bit how to implement reading based on type.
I can’t do it like this

Component
    |> Repo.get!(id)
    |> Repo.preload(:html)
    |> Repo.preload(:rss)

but you can do this:

component = Repo.get!(Component, id)
component = Repo.preload(component, component.type)

if type doesn’t match assoc (not an atom or different naming), create a helper function type_to_assoc_name/1 that will do this mapping.