fix: use provider object as hash key in ProviderStateRegistry#270
fix: use provider object as hash key in ProviderStateRegistry#270cristiangmarta wants to merge 1 commit intoopen-feature:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ProviderStateRegistry to use the provider object itself as the key in the internal states hash, replacing the previous usage of provider.object_id. Corresponding updates were made to the test suite to remove unnecessary object_id stubs from provider doubles. I have no feedback to provide.
There was a problem hiding this comment.
Pull request overview
This PR updates ProviderStateRegistry to key provider state by the provider object itself (instead of provider.object_id) to avoid Ruby 4.0 warnings caused by stubbing object_id in tests.
Changes:
- Switch
ProviderStateRegistryinternal@stateshash keys fromprovider.object_idtoprovider. - Update provider-state registry specs to stop stubbing
object_idon doubles.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spec/open_feature/sdk/provider_state_registry_spec.rb | Removes object_id stubs from provider doubles used in registry specs. |
| lib/open_feature/sdk/provider_state_registry.rb | Uses provider objects as hash keys for storing/retrieving/removing provider state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ider.object_id Signed-off-by: Cristian Marta <cristian@caffe-lento.com>
2790850 to
879cd8c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
provider.object_idas the hash key inProviderStateRegistrywithcompare_by_identity, making the internal@stateshash use object identity for key lookupobject_id:stubs from test doubles inprovider_state_registry_spec.rbMotivation
The original code used
provider.object_idas an integer key to track provider state by identity. This caused Ruby 4.0 warnings in tests:Using
{}.compare_by_identityis the idiomatic solution, it preserves the original semantics without callingobject_idat all.