Skip to content

Internalize versioning state behind Grape::Util::InheritableSetting accessors#2806

Open
ericproulx wants to merge 1 commit into
masterfrom
inheritable-setting-versioning
Open

Internalize versioning state behind Grape::Util::InheritableSetting accessors#2806
ericproulx wants to merge 1 commit into
masterfrom
inheritable-setting-versioning

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Second batch of the namespace_inheritable cleanup (after #2805; #2795#2804 covered the stackable side): the versioning state written by the version, prefix and cascade DSL methods is now recorded and read through intention-revealing accessors on Grape::Util::InheritableSetting.

New accessors on InheritableSetting

Accessor Replaces
version / version= namespace_inheritable[:version]
version_options / version_options= namespace_inheritable[:version_options]
root_prefix / root_prefix= namespace_inheritable[:root_prefix]
cascade / cascade= / cascade_defined? namespace_inheritable[:cascade] / .key?(:cascade)

Notes:

  • cascade is the one subtle key: an explicitly assigned nil is meaningful and distinct from never-set (InheritableValues#[] is key-presence based via fetch), so the accessor family includes cascade_defined?. Both presence checks — DSL::Routing#cascade's getter and Grape::API::Instance#cascade?'s fallback chain (explicit cascade → version_options.cascadetrue) — now read through it, and the semantics are documented on the accessor instead of implied at two call sites.
  • cascade lives in this PR rather than a flags PR because Instance#cascade? also reads version_options — keeping the whole fallback chain in one conversion avoids two standalone PRs editing the same method.
  • Converted call sites: DSL::Routing (version, prefix, cascade), Endpoint (to_routes, build_stack versioner setup — the reader absorbs nothing here since .flatten / .present? are caller concerns), Grape::API::Instance#cascade?, and the DSL::VersionOptions doc comment.
  • These are nearest-wins scalars, so writers use plain = (see Internalize format and error-response defaults behind Grape::Util::InheritableSetting accessors #2805 for the naming rationale).
  • Storage under the raw keys is unchanged; they should now be considered internal. Specs assert through the accessors.

🤖 Generated with Claude Code

…ccessors

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Danger Report

No issues found.

View run

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