• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 26370276319 / 37
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: robust_mounted_app_comparison
DEFAULT BRANCH: master
Ran 24 May 2026 07:13PM UTC
Files 163
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

24 May 2026 07:12PM UTC coverage: 95.433% (-0.3%) from 95.688%
26370276319.37

Pull #2718

github

ericproulx
Generalize middleware options to per-class Data value objects

Following the per-feature `VersionOptions` / `RescueOptions` work in #2712
and #2716, middlewares that want typed option accessors now declare a
per-class `Options = Data.define(...)`.

## Mechanism

`Middleware::Base#initialize`, when the subclass declares an `Options`
constant (ancestor search included), routes the kwargs through
`Options.new(**options)`:

- `@config` exposes the typed Data instance (named accessors).
- `@options` keeps returning a frozen `Hash` representation
  (`config.to_h.freeze`) for back-compat with subclasses that read
  `options[:key]`.

Subclasses without an `Options` constant still flow through the
`DEFAULT_OPTIONS` Hash + `deep_merge` path (`Filter`, `Auth::*`) unchanged.

## Converted middlewares

- `Middleware::Formatter` (5 fields).
- `Middleware::Error` (14 fields). `rescue_options:` defaults to
  `Grape::DSL::RescueOptions.new`; an explicit nil (passed by
  `Endpoint#error_middleware_options` when no `rescue_from` was called)
  is coerced to the default in the initializer.
- `Middleware::Versioner::Base` (7 fields). Adds `content_types:` /
  `format:` so the `PrecomputedContentTypes` mixin's accessor reads land
  cleanly. `version_options:` defaults to `Grape::DSL::VersionOptions.new`.

Each `Options` field list is alphabetic.

## Back-compat surface

- `attr_reader :options` still returns a frozen `Hash` for converted
  middlewares (now derived from `config.to_h`). Subclasses that read
  `options[:key]` keep working.
- `DEFAULT_OPTIONS` is restored as `Options.new.to_h.freeze` on each
  converted middleware so existing references continue to resolve.
  Marked `@deprecated` in the YARD comment; will be removed in a future
  release.
- `Options#[]` is defined on each Data class as a Hash-style shim that
  emits a deprecation warning via `Grape.deprecator` and forwards to
  the named accessor — gives any code that discovers the Data and
  reaches in with `[... (continued)
Pull Request #2718: [DRAFT] Generalize middleware options to per-class Data value objects

1062 of 1177 branches covered (90.23%)

Branch coverage included in aggregate %.

3472 of 3574 relevant lines covered (97.15%)

983.93 hits per line

Source Files on job run-3.4-gemfiles/rack_3_0.gemfile - 26370276319.37
  • Tree
  • List 163
  • Changed 10
  • Source Changed 10
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 26370276319
  • 6fc81d90 on github
  • Prev Job for on draft/middleware-options-data (#26292056269.24)
  • Next Job for on draft/middleware-options-data (#26370397176.13)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc