Add ability to specify specific struct class for auto_struct

#1

An issue that has come up fairly regularly for us is that structs will map to an unintended classes when using auto_struct. One such case in when an association is aliased. Something like

# we want it to map to this
class PostCategory
end

class Post < ROM::Relation[:posts]
  schema do
    associations do
      has_one :post_category, as: :category
    end
  end
end

# the hacky fix
Category = PostCategory

What do you think about offering an option like: entity_implementation PostCategory? I think this would be much more predictable and won’t fail in confusing ways. Thoughts?

#2

hey @ianks! We have a similar thread over here Aliased association doesn't map to the entity of the relation please chime in there. We could add this feature in 5.1.0 because we’re wrapping up 5.0.0 this week.