rom
rom copied to clipboard
Make default dataset available within the dataset configuration block
A common scenario is when you want to adjust the default dataset rather than setting it up from scratch, that's why it will be convenient when the default dataset is available within the Relation.dataset
configuration block.
Probably the best way to do this is to tweak Gateway#dataset
so that it can also accept a schema because we have it available already when dataset is retrieved from the gateway. This way the gateway will be responsible for returning the default dataset in rom-sql too (right now we use a configuration event for this). A huge benefit of this approach is that we won't have to introduce any new interface and/or change the behavior of the dataset block.
Resources
- Relevant part of the finalization code where the dataset block is evaluated: https://github.com/rom-rb/rom/blob/master/core/lib/rom/setup/finalize/finalize_relations.rb#L97
- Setting up the default dataset in rom-sql: https://github.com/rom-rb/rom-sql/blob/master/lib/rom/sql/relation.rb#L34-L43
- rom-sql's
Gateway#dataset
method: https://github.com/rom-rb/rom-sql/blob/master/lib/rom/sql/gateway.rb#L136-L138 - Discussion forum thread