From cf6e53061060ce5cf0426150aaca93b752ef584a Mon Sep 17 00:00:00 2001 From: Loren Segal Date: Sun, 9 Apr 2023 12:15:37 -0700 Subject: [PATCH] No longer use refinements with Rack::Request --- CHANGELOG.md | 2 ++ lib/yard/server/rack_adapter.rb | 18 +++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd2c72e50..33dfb81d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # main +- Fix issue with custom Rack::Request attributes in `yard server` + # 0.9.31 - April 9th, 2023 [0.9.31]: https://github.com/lsegal/yard/compare/v0.9.30...v0.9.31 diff --git a/lib/yard/server/rack_adapter.rb b/lib/yard/server/rack_adapter.rb index 06f757ed0..453381f63 100644 --- a/lib/yard/server/rack_adapter.rb +++ b/lib/yard/server/rack_adapter.rb @@ -12,16 +12,6 @@ module Server RackServer = Rack::Server end - # Safely use refinements since Rack requires 2.4+ - # @private - module RackRefinements - refine Rack::Request do - attr_accessor :version_supplied - alias query params - def xhr?; (env['HTTP_X_REQUESTED_WITH'] || "").casecmp("xmlhttprequest") == 0 end - end - end - # This class wraps the {RackAdapter} into a Rack-compatible middleware. # See {#initialize} for a list of options to pass via Rack's +#use+ method. # @@ -61,7 +51,6 @@ def call(env) # A server adapter to respond to requests using the Rack server infrastructure. class RackAdapter < Adapter include YARD::Server::HTTPUtils - using RackRefinements # Responds to Rack requests and builds a response with the {Router}. # @return [Array(Numeric,Hash,Array)] the Rack-style response @@ -99,3 +88,10 @@ def print_start_message(server) end end end + +# @private +class Rack::Request + attr_accessor :version_supplied + alias query params + def xhr?; (env['HTTP_X_REQUESTED_WITH'] || "").casecmp("xmlhttprequest") == 0 end +end