A registry task that spawns a registry scoped to this request.
You must provide a locked registry configuration to use as a template. The spawned registry will use the given configuration. You must also provide a key, which will be used to store the spawned registry in the Rack environment so that your application can access it.
Create a new ClearRegistry task. You must provide a locked template configuration and a key into the Rack environment.
# File lib/idregistry/middleware.rb, line 102 def initialize(template_, envkey_) @template = template_ @envkey = envkey_ @registry = nil end
The post method for this task clears the spawned registry.
# File lib/idregistry/middleware.rb, line 114 def post(env_) if @registry @registry.clear @registry = nil env_.delete(@envkey) end end
The pre method for this task creates a new registry.
# File lib/idregistry/middleware.rb, line 109 def pre(env_) @registry = env_[@envkey] = @template.spawn_registry end