Module: ActiveRecord::RuntimeRegistry

Extended by:
RuntimeRegistry
Included in:
RuntimeRegistry
Defined in:
lib/active_record/runtime_registry.rb

Overview

This is a thread locals registry for Active Record. For example:

ActiveRecord::RuntimeRegistry.sql_runtime

returns the connection handler local to the current unit of execution (either thread of fiber).

Instance Method Summary collapse

Instance Method Details

#async_sql_runtimeObject



20
21
22
# File 'lib/active_record/runtime_registry.rb', line 20

def async_sql_runtime
  ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] ||= 0.0
end

#async_sql_runtime=(runtime) ⇒ Object



24
25
26
# File 'lib/active_record/runtime_registry.rb', line 24

def async_sql_runtime=(runtime)
  ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] = runtime
end

#resetObject



28
29
30
31
32
# File 'lib/active_record/runtime_registry.rb', line 28

def reset
  rt, self.sql_runtime = sql_runtime, 0.0
  self.async_sql_runtime = 0.0
  rt
end

#sql_runtimeObject



12
13
14
# File 'lib/active_record/runtime_registry.rb', line 12

def sql_runtime
  ActiveSupport::IsolatedExecutionState[:active_record_sql_runtime] ||= 0.0
end

#sql_runtime=(runtime) ⇒ Object



16
17
18
# File 'lib/active_record/runtime_registry.rb', line 16

def sql_runtime=(runtime)
  ActiveSupport::IsolatedExecutionState[:active_record_sql_runtime] = runtime
end