This adds support for auto-loading of component files using Zeitwerk. All you need to do is this:
rom = ROM.runtime(:sql, "sqlite::memory") do |cfg|
cfg.auto_register("path-to-component-dir", auto_load: true) # <= that's it
end
Once this is enabled, whenever you ask for a rom component, it will infer fully qualified constant name based on component's key and try to load a corresponding file using Zeitwerk auto-loading, ie:
This adds support for auto-loading of component files using Zeitwerk. All you need to do is this:
Once this is enabled, whenever you ask for a rom component, it will infer fully qualified constant name based on component's key and try to load a corresponding file using Zeitwerk auto-loading, ie:
rom.relations[:users]
=>Relations::Users
=>#{components_dir}/relations/users
rom.mappers[:users][:listing]
=>Mappers::Users::Listing
=>#{components_dir}/mappers/users/listing
If you have top-level namespace enabled, it will be prepended automatically, ie:
rom.relations[:users]
=>Persistence::Relations::Users
=>#{components_dir}/persistence/relations/users
rom.mappers[:users][:listing]
=>Persistence::Mappers::Users::Listing
=>#{components_dir}/persistence/mappers/users/listing