Skip to content

Make requirements and anchor first-class endpoint inputs#2786

Open
ericproulx wants to merge 1 commit into
untangle_route_paramsfrom
explicit_route_options
Open

Make requirements and anchor first-class endpoint inputs#2786
ericproulx wants to merge 1 commit into
untangle_route_paramsfrom
explicit_route_options

Conversation

@ericproulx

Copy link
Copy Markdown
Contributor

Stacked on #2785.

Follows the same direction as #2785 (first-class params): route's two documented, Grape-consumed options — requirements: and anchor: — become explicit keyword arguments instead of opaque keys read out of the route_options bag. **route_options still catches any custom options (e.g. grape-swagger metadata passed inline).

What changed

  • route(methods, paths, requirements: nil, anchor: true, **route_options, &) — the two documented options are now named parameters; everything else flows through **route_options as before.
  • Grape::Endpoint::Options gains :requirements and :anchor members, and Grape::Endpoint.new matching requirements: / anchor: keywords.
  • to_routes reads config.requirements / config.anchor instead of route_options[:requirements] / route_options.fetch(:anchor, true).
  • mount passes anchor: false as a keyword rather than route_options: { anchor: false }.
  • The verb methods (get/post/…) are left as pure **options forwarders — route is the single source of truth for these options and their defaults.

Behavior

UPGRADING updated (the #2779 caveat corrected + a parallel note added). Full suite green (2353 examples, 0 failures); RuboCop clean.

🤖 Generated with Claude Code

@ericproulx ericproulx force-pushed the explicit_route_options branch from 549990d to d69ead8 Compare July 6, 2026 09:40
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@ericproulx ericproulx force-pushed the untangle_route_params branch from 21695b8 to 2e21378 Compare July 6, 2026 09:57
@ericproulx ericproulx force-pushed the explicit_route_options branch from d69ead8 to 269e2b3 Compare July 6, 2026 10:12
@ericproulx ericproulx requested a review from dblock July 6, 2026 10:17
@ericproulx

Copy link
Copy Markdown
Contributor Author

@dblock this is a stack PR.

`route`'s documented options `requirements:` and `anchor:` are now explicit
keyword arguments rather than opaque keys in the `route_options` bag, with
`**route_options` still catching any custom options. They travel as their
own endpoint inputs (`Grape::Endpoint::Options` gains `:requirements` and
`:anchor` members; `Grape::Endpoint.new` gains matching keywords) and
`to_routes` reads them via `config.requirements` / `config.anchor` instead
of `route_options[...]`. The verb methods forward `**options` unchanged, so
`get(':id', requirements: {...}, anchor: false)` still works.

Like `params`, they no longer appear in `route.options`; the effective value
comes from the `route.requirements` / `route.anchor` readers. Mounts pass
`anchor: false` as a keyword too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the explicit_route_options branch from 269e2b3 to cfaebfd Compare July 6, 2026 11:03
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