+3
−3
Loading
The kwarg lives on `Limiter#check`/`#peek` — it's per-request data the
caller passes in, not configuration baked onto the Rule. `rule_extras:`
read at a call site as "extra fields the rule was built with," which
inverted the actual lifetime. `rule_context:` matches the docstring
("per-request context passed to one-arity callables") and the
`rule_` qualifier avoids collision with the gem's `Labkit::Context`.
Cheaper to rename pre-merge than after the cohort-4 consumer picks it up.
Also fix a backward-compat regression in `resolve_value`: calling
`val.arity` unconditionally raises `NoMethodError` for callable objects
that respond to `:call` but not `:arity` (e.g. a plain class with
`def call`). The error gets swallowed by the outer `rescue StandardError`
in `check`/`peek`, producing a silent fail-open with a misleading
`rate_limit_error` log line. Guard with `respond_to?(:arity)` so such
callables take the zero-arg path, preserving the original API contract.
Regression spec added for the no-arity callable path. Suite: 326 examples
(325 + 1), 0 failures.
Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>