Skip to content

Conversation

solnic
Copy link
Member

@solnic solnic commented Dec 28, 2021

This makes inferring relation ids from constant names explicitly configurable, which will make things much simpler to handle. This behavior was previously implicit and caused a lot of pain in the code.

You can configure it "globally" within your runtime or on a per-relation class basis.

> runtime = ROM::Runtime.new { |runtime| runtime.config.relation.infer_id_from_class = true }
=> #<ROM::Runtime:0x00007f6d4790bc10..>
irb(main):005:0> class Users < ROM::Relation; end
=> nil
irb(main):006:0> runtime.register_relation(Users)
=> [#<ROM::Components::Relation:0x00007f6d479b2740...]
> runtime.resolver["relations.users"]
=> #<Users name=ROM::Relation::Name(users) dataset=[]>

This can be done relatively easily for other component types too.

@solnic solnic added this to the 6.0.0 milestone Dec 28, 2021
@solnic solnic merged commit 73523bd into master Dec 28, 2021
@solnic solnic deleted the add-optional-component-id-inference-to-relations branch December 28, 2021 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant