In my Rails 3.2 application, I have to call a method on a middleware instance of a particular class type.
I tried to use Rails.application.middleware , but it does not work because it only wraps middleware classes, not their instances.
Now I go through the middleware chain starting with Rails.application.app using Ruby instance_variable_get and is_a? but thatβs not very good, especially because there is no specific way that staging stores the context. For example, Rack::Cache::Context stores the next instance in a variable named @backend , while most others use @app .
Is there a better way to find a middleware instance?
source share