steveklabnik / request_store

Per-request global storage for Rack.
https://github.com/steveklabnik/request_store
MIT License
1.48k stars 87 forks source link

add RequestStore.init #6

Closed timoschilling closed 11 years ago

timoschilling commented 11 years ago

i think it is a better way to handle the init/clear functionality in the RequestStore module

steveklabnik commented 11 years ago

Hmmm. I'm gonna think about this: the library right now is REALLY SIMPLE and adding a class << self kinda makes me want to cry ;)

timoschilling commented 11 years ago

true class << self is not nice, but clear and init ar tow different thinks. What are the other options?

  1. use one method for clear and init? what should the name of the method?
  2. we make tow methods with the same logic?
steveklabnik commented 11 years ago

The other option is to leave it as it is.

timoschilling commented 11 years ago

What's about RequestStore.init_or_clear? Then we don't have the Thread.current[:request_store] = {} in the middelware and only one method and don't need to use class << self; alias ...

One other argument for an internal init way is, (i plan a new pull request for that) to configure the internal store, so that the developer can change it.

steveklabnik commented 11 years ago

Closed in favor of #7.