Class: CustomLogSpace::ThreadManager
- Inherits:
-
Object
- Object
- CustomLogSpace::ThreadManager
- Defined in:
- lib/custom_log_space/base_helper/thread_manager.rb
Overview
The ThreadManager class provides methods for managing thread-local variables related to logging in a Rails application. It is responsible for setting up and clearing thread-local variables such as controller, action, path, params, and header_written.
Class Method Summary collapse
- .clear ⇒ Object
-
.setup(payload) ⇒ Object
railsguides.jp/v6.1/active_support_instrumentation.html#start-processing-action-controller Sets up thread-local variables based on the provided payload.
Class Method Details
.clear ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/custom_log_space/base_helper/thread_manager.rb', line 31 def self.clear Thread.current[:current_controller] = nil Thread.current[:current_action] = nil Thread.current[:path] = nil Thread.current[:params] = nil Thread.current[:header_written] = nil end |
.setup(payload) ⇒ Object
railsguides.jp/v6.1/active_support_instrumentation.html#start-processing-action-controller Sets up thread-local variables based on the provided payload.
Example:
payload = {
controller: 'HomeController',
action: 'index',
path: '/home',
params: { id: 1, page: 2 }
}
CustomLogSpace::ThreadManager.setup(payload)
23 24 25 26 27 28 29 |
# File 'lib/custom_log_space/base_helper/thread_manager.rb', line 23 def self.setup(payload) Thread.current[:current_controller] = payload[:controller] Thread.current[:current_action] = payload[:action] Thread.current[:path] = payload[:path] Thread.current[:params] = payload[:params].except(:controller, :action) Thread.current[:header_written] = false end |