class ScoutApm::Instruments::MiddlewareSummary::MiddlewareSummaryWrapper
Public Class Methods
Source
# File lib/scout_apm/instruments/middleware_summary.rb, line 50 def initialize(app) @app = app end
Public Instance Methods
Source
# File lib/scout_apm/instruments/middleware_summary.rb, line 54 def call(env) req = ScoutApm::RequestManager.lookup layer = ScoutApm::Layer.new("Middleware", "Summary") req.start_layer(layer) @app.call(env) ensure req.stop_layer end
Source
# File lib/scout_apm/instruments/middleware_summary.rb, line 77 def method_missing(sym, *arguments, &block) if @app.respond_to?(sym) @app.send(sym, *arguments, &block) else super end end
Some code (found in resque_web initially) attempts to call methods directly on ‘MyApplication.app`, which is the middleware stack. If it hits our middleware instead of the object at the root of the app that it expected, then a method it expects will not be there, and an error thrown.
Specifically, resque_web assumes ‘ResqueWeb::Engine.app.url_helpers` is a method call on rails router for its own Engine, when in fact, we’ve added a middleware before it.
So method_missing
just proxies anything to the nested @app object
While method_missing
is not very performant, this is only here to handle edge-cases in other code, and should not be regularly called
Calls superclass method
Source
# File lib/scout_apm/instruments/middleware_summary.rb, line 85 def respond_to?(sym, include_private = false) if @app.respond_to?(sym, include_private) true else super end end
Calls superclass method