Permalink
Browse files

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.
  • Loading branch information...
1 parent a548c45 commit 11c697383e6fea7834ee1a8ba2815ff0da20f0fe @fxn fxn committed Apr 13, 2013
@@ -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

0 comments on commit 11c6973

Please sign in to comment.