Class: IDRegistry::Railtie::Configuration
- Inherits:
-
Object
- Object
- IDRegistry::Railtie::Configuration
- Defined in:
- lib/idregistry/railtie.rb
Overview
Configuration options. These are methods on config.idregistry.
Instance Attribute Summary collapse
-
#before_middleware ⇒ Object
Middleware to run before, or nil to run the middleware toward the end.
-
#tasks ⇒ Object
Array of registry tasks.
Instance Method Summary collapse
-
#clear_registry(reg_, opts_ = {}, &condition_) ⇒ Object
Set up the middleware to clear the given registry after each request.
-
#initialize ⇒ Configuration
constructor
:nodoc:.
-
#spawn_registry(template_, envkey_) ⇒ Object
Set up the middleware to spawn a new registry on each request, using the given locked configuration as a template.
Constructor Details
#initialize ⇒ Configuration
:nodoc:
65 66 67 68 |
# File 'lib/idregistry/railtie.rb', line 65 def initialize # :nodoc: @tasks = [] @before_middleware = nil end |
Instance Attribute Details
#before_middleware ⇒ Object
Middleware to run before, or nil to run the middleware toward the end
75 76 77 |
# File 'lib/idregistry/railtie.rb', line 75 def before_middleware @before_middleware end |
#tasks ⇒ Object
Array of registry tasks
72 73 74 |
# File 'lib/idregistry/railtie.rb', line 72 def tasks @tasks end |
Instance Method Details
#clear_registry(reg_, opts_ = {}, &condition_) ⇒ Object
Set up the middleware to clear the given registry after each request.
If you provide the optional block, it is called and passed the Rack environment. The registry is cleared only if the block returns a true value. If no block is provided, the registry is always cleared at the end of a request.
If you set the :before_request
option to true, the registry clearing will take place at the beginning of the request rather than the end.
90 91 92 93 |
# File 'lib/idregistry/railtie.rb', line 90 def clear_registry(reg_, opts_={}, &condition_) @tasks << RegistryMiddleware::ClearRegistry.new(reg_, opts_, &condition_) self end |
#spawn_registry(template_, envkey_) ⇒ Object
Set up the middleware to spawn a new registry on each request, using the given locked configuration as a template. The new registry is stored in the Rack environment with the given key. It is cleaned and disposed at the end of the request.
101 102 103 104 |
# File 'lib/idregistry/railtie.rb', line 101 def spawn_registry(template_, envkey_) @tasks << RegistryMiddleware::SpawnRegistry.new(template_, envkey_) self end |