removes calls to AR::Runtime.instance
Registries have class-level accessors to write clean code, let's use them. This makes style uniform also with existing usage in ScopeRegistry and InstrumentationRegistry. If performance of the method_missing callback was ever considered to be a concern, then we should stop using it altogether and probably remove the callback. But while we have the feature we should use it.
This commit is contained in:
parent
a548c4591b
commit
11c697383e
@ -54,11 +54,11 @@ def connection
|
||||
end
|
||||
|
||||
def connection_id
|
||||
ActiveRecord::RuntimeRegistry.instance.connection_id
|
||||
ActiveRecord::RuntimeRegistry.connection_id
|
||||
end
|
||||
|
||||
def connection_id=(connection_id)
|
||||
ActiveRecord::RuntimeRegistry.instance.connection_id = connection_id
|
||||
ActiveRecord::RuntimeRegistry.connection_id = connection_id
|
||||
end
|
||||
|
||||
# Returns the configuration of the associated connection as a hash:
|
||||
|
@ -80,11 +80,11 @@ module Core
|
||||
class_attribute :default_connection_handler, instance_writer: false
|
||||
|
||||
def self.connection_handler
|
||||
ActiveRecord::RuntimeRegistry.instance.connection_handler || self.default_connection_handler
|
||||
ActiveRecord::RuntimeRegistry.connection_handler || default_connection_handler
|
||||
end
|
||||
|
||||
def self.connection_handler=(handler)
|
||||
ActiveRecord::RuntimeRegistry.instance.connection_handler = handler
|
||||
ActiveRecord::RuntimeRegistry.connection_handler = handler
|
||||
end
|
||||
|
||||
self.default_connection_handler = ConnectionAdapters::ConnectionHandler.new
|
||||
|
@ -3,11 +3,11 @@ class LogSubscriber < ActiveSupport::LogSubscriber
|
||||
IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"]
|
||||
|
||||
def self.runtime=(value)
|
||||
ActiveRecord::RuntimeRegistry.instance.sql_runtime = value
|
||||
ActiveRecord::RuntimeRegistry.sql_runtime = value
|
||||
end
|
||||
|
||||
def self.runtime
|
||||
ActiveRecord::RuntimeRegistry.instance.sql_runtime ||= 0
|
||||
ActiveRecord::RuntimeRegistry.sql_runtime ||= 0
|
||||
end
|
||||
|
||||
def self.reset_runtime
|
||||
|
Loading…
Reference in New Issue
Block a user