Skip to content

Implement Namespaces - #4

Merged
kinnell merged 1 commit into
mainfrom
catalog
Feb 24, 2026
Merged

Implement Namespaces#4
kinnell merged 1 commit into
mainfrom
catalog

Conversation

@kinnell

@kinnell kinnell commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Description

This PR serves to decouple enum field registration from ActiveRecord models by introducing a namespace concept to the registry. Definitions can now be registered standalone via EnumFields.namespace(:name) { enum_field ... }, making the gem useful for centralizing enum definitions in initializers or shared configuration without requiring a backing model.

In addition, a new EnumFields.catalog method provides a sorted, serialization-friendly view of all registered definitions across both model-derived and standalone namespaces.

@kinnell kinnell self-assigned this Feb 24, 2026
@kinnell kinnell changed the title Add ability to define enum_fields outside of models & create catalog Implement Namespaces Feb 24, 2026
@kinnell
kinnell requested a review from Copilot February 24, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a namespace-based architecture for enum field registration, decoupling it from ActiveRecord models. The changes enable standalone enum field definitions that can be registered in initializers or shared configuration without requiring a backing model.

Changes:

  • Refactored EnumFields.register to accept namespace instead of model_class parameter
  • Added EnumFields.namespace DSL for standalone enum field registration outside models
  • Added EnumFields.catalog method to provide alphabetically-sorted, serialization-friendly view of all registered definitions

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/enum_fields.rb Added namespace and catalog class methods to support new DSL and data export
lib/enum_fields/registry.rb Refactored register to accept namespace parameter and added catalog method for sorted output
lib/enum_fields/namespace.rb New class providing DSL context for standalone enum field registration
lib/enum_fields/enum_field.rb Updated to derive namespace from model class name when registering
spec/enum_fields/registry.spec.rb Comprehensive test updates covering new namespace DSL, catalog functionality, and edge cases
README.md Added documentation for standalone registration via namespace DSL and catalog method
.rubocop.yml Updated target Ruby version from 2.7 to 3.4

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .rubocop.yml
Comment thread README.md Outdated
Comment thread README.md Outdated
@kinnell
kinnell merged commit 7f1d688 into main Feb 24, 2026
2 checks passed
@kinnell
kinnell deleted the catalog branch February 24, 2026 08:24
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.

2 participants