- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (4)
- 5.1.7 (1)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2
- 7.1.3.4
- What's this?
NOTE: This approach has been deprecated for end-user code in favor of {thread_mattr_accessor}[rdoc-ref:Module#thread_mattr_accessor] and friends. Please use that approach instead.
This module is used to encapsulate access to thread local variables.
Instead of polluting the thread locals namespace:
Thread.current[:connection_handler]
you define a class that extends this module:
module ActiveRecord class RuntimeRegistry extend ActiveSupport::PerThreadRegistry attr_accessor :connection_handler end end
and invoke the declared instance accessors as class methods. So
ActiveRecord::RuntimeRegistry.connection_handler = connection_handler
sets a connection handler local to the current thread, and
ActiveRecord::RuntimeRegistry.connection_handler
returns a connection handler local to the current thread.
This feature is accomplished by instantiating the class and storing the instance as a thread local keyed by the class name. In the example above a key “ActiveRecord::RuntimeRegistry” is stored in Thread.current. The class methods proxy to said thread local instance.
If the class has an initializer, it must accept no arguments.