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

dblock / grape / 27287147098

04 Jun 2026 04:09PM UTC coverage: 96.839% (-0.04%) from 96.883%
27287147098

push

github

web-flow
Build the cookie jar only on use and drop its deferral Proc (#2757)

Two related steps that make the response-cookie path lazy at the request
boundary:

- `build_response_cookies` runs on every request and went through
  `cookies` -> `request.cookies`, materializing the `Grape::Cookies` jar
  even when the handler never touched a cookie. Gate it on a new
  `Grape::Request#cookies?` predicate (true only once the jar exists),
  so a cookie-free request allocates no jar at all.

- With the jar now built only when a cookie is actually read or written,
  its `-> { rack_cookies }` deferral Proc no longer earns its keep: any
  access immediately forces the parse, and a write (`[]=`) always did.
  Parse `rack_cookies` eagerly in the constructor and replace the
  `is_a?(Proc)` lazy reader with a plain `attr_reader`, dropping the
  closure allocation and the per-access branch.

The `ActiveSupport::HashWithIndifferentAccess` wrapping is unchanged --
it backs Grape's string/symbol-indifferent cookie access.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

1114 of 1205 branches covered (92.45%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 3 files covered. (100.0%)

31 existing lines in 18 files now uncovered.

3543 of 3604 relevant lines covered (98.31%)

23211.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.77
/lib/grape/validations/validators/base.rb


Source Not Available

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