I'm using Rack middleware that accepts some configuration that I need to change at run time. So I need the instance of its class that's currently in memory. Is there a way to do obtain it?
I would follow an other way instead.
If you are using Rails 3, you can write the Rack middleware so that it accesses the shared application configuration available at Rails::Application.config
. Otherwise, no matter which is your Rails version, you can use a configuration library (such as the simple_config
gem) and keep the current configuration value in memory so that the Middleware can access it.
Last but not least, remember that Rack has a Rack::Config
middleware that you can adapt to your needs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.