Class: IDRegistry::Railtie::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/idregistry/railtie.rb

Overview

Configuration options. These are methods on config.idregistry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

:nodoc:



65
66
67
68
# File 'lib/idregistry/railtie.rb', line 65

def initialize  # :nodoc:
  @tasks = []
  @before_middleware = nil
end

Instance Attribute Details

#before_middlewareObject

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

#tasksObject

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