Skip to content

Internalize format and error-response defaults behind Grape::Util::InheritableSetting accessors#2805

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

Internalize format and error-response defaults behind Grape::Util::InheritableSetting accessors#2805
ericproulx wants to merge 1 commit into
masterfrom
inheritable-setting-format-defaults

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Starts the namespace_inheritable half of the InheritableSetting cleanup (#2795#2804 covered the stackable side): the serialization and error-response defaults written by the format, default_format, default_error_formatter and default_error_status DSL methods are now recorded and read through intention-revealing accessors on Grape::Util::InheritableSetting.

New accessors on InheritableSetting

Accessor Replaces
format / format= namespace_inheritable[:format]
default_format / default_format= namespace_inheritable[:default_format]
default_error_formatter / default_error_formatter= namespace_inheritable[:default_error_formatter]
default_error_status / default_error_status= namespace_inheritable[:default_error_status]

Notes:

  • Naming: these are nearest-wins scalars — a nested scope's assignment overrides an inherited value — so the writers use plain = rather than the add_* naming reserved for stackable registrations. The naming now documents the semantics.
  • Converted call sites: DSL::RequestResponse (all four get-or-set DSL methods), Endpoint (initialize's default_error_status ||= 500 seeding, build_stack, error_middleware_options) and DSL::InsideRoute#error!. With this, error_middleware_options no longer touches any raw store.
  • Storage under the raw keys is unchanged, so to_hash output and any external readers see the same values; the raw keys should now be considered internal.
  • Specs assert through the accessors.

🤖 Generated with Claude Code

…heritableSetting accessors

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