rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.07k stars 161 forks source link

1st class schemas #644

Closed solnic closed 3 years ago

solnic commented 3 years ago

Schemas are now part of the runtime, lazy-loaded and configured just like all other components, and they are decoupled from relations now.

This drastically simplified handling everything that may need access to schemas and further simplifications are still possible.

This has a temporary breaking change because Relation.dataset receives a schema now, instead of a relation class. I will restore original behavior in rom/compat later on in a PR that will improve handling of the default dataset (this is part of 6.0.0 feature scope).

Apart from lazy-loading, there's another big benefit of this refactor - relation classes no longer hold their schemas as class variables. This means that the same relation class can be re-used in the same process in different configurations. It also means that standard inheritance will be finally possible.