Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a globally accessible EnumFields::Registry to index enum field definitions by underscored model name, enabling cross-model lookup/introspection of registered enum fields.
Changes:
- Added
EnumFields::Registry(a hash-like store with indifferent access) plusEnumFields.registry,EnumFields.register, andEnumFields.clear_registry!. - Hooked
EnumField#define!to automatically register everyenum_fielddefinition into the global registry. - Added comprehensive specs for registry behavior and ensured test isolation by clearing the registry before each example.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| spec/spec_helper.rb | Clears the global registry before each spec to avoid cross-example state leakage. |
| spec/enum_fields/registry.spec.rb | Adds coverage for registry access, key normalization, integration with enum_field, and clearing behavior. |
| lib/enum_fields/registry.rb | Implements the new Registry store and #register behavior. |
| lib/enum_fields/enum_field.rb | Registers definitions into the global registry during define!. |
| lib/enum_fields.rb | Adds autoload + module-level registry helpers (registry, register, clear_registry!). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR serves to introduce an
EnumFields::Registrythat provides a centralized, globally-accessible index of all enum field definitions keyed by model name, enabling cross-model lookup and introspection of registered enum fields.