Hi there, newbie rom-rb user here, and this is probably a stupid question, will be happy to know if this completely violates rom patterns.
In repositories, is there a way to combine
and relation, but mapping it to different namespace than the root
relation?
Example:
class Entities::Company < ROM::Struct
end
class Entities::Companies::Employee < ROM::Struct
end
class Persistence::CompaniesRelation < ROM::Relation
schema :companies do
associations do
has_many :employees
end
end
end
class Persistence::Companies::EmployeesRelation < ROM::Relation
schema :employees do
associations do
belongs_to :company
end
end
end
class Domain::CompaniesRepo < ROM::Repository[:companies]
struct_namespace Domain::Entities
def find(id)
companies.combine(:employees).by_pk(id).one!
end
end
# when calling Domain::CompaniesRepo#find
# => <Domain::Entities::Company :employees=[<Domain::Entities::Employee (...) >
Is there an option in combine
that would allow me to change the struct_namespace
from Domain::Entities
to Domain::Entities::Companies
for that specific node?
Thanks for all the help in advance!