Adding `params` and `session` and `env` to Object

点点圈 提交于 2019-12-20 04:40:52

问题


In a gem I'm writing I am trying to add the rack methods params, session, and env to Object so that they can be accessed and modified by the user of the gem. I have tried using Object.instance_variable_set and Object.instance_variable_get to add the variables to Object and then set them again by retrieving them from Object. I have been using the Rack::Request.new(env) interface to do this. The only problem is that it seems to be impossible to set params and session through this object. This has led be to believe that I am doing something very wrong. How can I set params and session through Rack::Request? Please also let me know if what I'm doing is bad practice or if there is a better way of doing it.

来源:https://stackoverflow.com/questions/38675366/adding-params-and-session-and-env-to-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!