Internalize namespace and mount-path registrations behind Grape::Util::InheritableSetting accessors#2803
Open
ericproulx wants to merge 1 commit into
Open
Internalize namespace and mount-path registrations behind Grape::Util::InheritableSetting accessors#2803ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
…::InheritableSetting accessors Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Danger ReportNo issues found. |
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.
Continues the
InheritableSettingcleanup from #2795–#2802: theGrape::Namespaceobjects registered by thenamespaceDSL (and itsgroup/resource/resources/segmentaliases) and the mount path recorded bymountare now written and read through intention-revealing accessors onGrape::Util::InheritableSetting, so no caller indexes intonamespace_stackablefor these keys anymore.New accessors on
InheritableSettingnamespaces/add_namespace(namespace)namespace_stackable[:namespace]namespace_pathGrape::Namespace.joined_space_path(namespace_stackable[:namespace])namespace_requirementsnamespace_stackable[:namespace].filter_map(&:requirements)mount_path/add_mount_path(path)namespace_stackable[:mount_path]/.firstNotes:
namespace_pathperforms the joined-and-normalized prefix lookup used by bothEndpoint#namespaceand thenamespaceDSL getter, andnamespace_requirementsperforms the requirementsfilter_mapused byEndpoint#prepare_routes_requirements(still returning a fresh Array, which that call site appends to).mount_pathabsorbs the outermost-wins.firstpreviously done inEndpoint#build_stackwhen configuring the versioner middleware, and documents it: with nested mounts the stack carries one entry per mount level, outermost first. The write side (add_mount_path) is recorded on the mounted API's top-level settings byDSL::Routing#mount, as before.namespaces(plural) becauseInheritableSetting#namespacealready exists as the reader for theInheritableValuesnamespace store; the doc comments call out the distinction.@paramdoc onGrape::Namespace.joined_space_path, which claimed the argument is a list ofInheritableSettings — it has always been a list ofGrape::Namespaceobjects.to_hashoutput, route pattern settings (settings[:mount_path]inRouter::Pattern::Path, which reads the stacked Array viato_hash) and any external readers see the same values; the raw keys should now be considered internal.🤖 Generated with Claude Code