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 = []
  @after_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_, &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.



86
87
88
89
# File 'lib/idregistry/railtie.rb', line 86

def clear_registry(reg_, &condition_)
  @tasks << RegistryMiddleware::ClearRegistry.new(reg_, &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.



97
98
99
100
# File 'lib/idregistry/railtie.rb', line 97

def spawn_registry(template_, envkey_)
  @tasks << RegistryMiddleware::SpawnRegistry.new(template_, envkey_)
  self
end