Skip to content

Commit

Permalink
Refactor AbstractAdapter#initialize
Browse files Browse the repository at this point in the history
`pool` in args is unused anymore. And `config` is used in all adapters.
  • Loading branch information
kamipo committed Nov 30, 2015
1 parent ac26573 commit 8c53b20
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ def self.type_cast_config_to_boolean(config)

attr_reader :prepared_statements

def initialize(connection, logger = nil, pool = nil) #:nodoc:
def initialize(connection, logger = nil, config = {}) # :nodoc:
super()

@connection = connection
@owner = nil
@instrumenter = ActiveSupport::Notifications.instrumenter
@logger = logger
@pool = pool
@config = config
@pool = nil
@schema_cache = SchemaCache.new self
@visitor = nil
@prepared_statements = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ def attributes_for_hash

# FIXME: Make the first parameter more similar for the two adapters
def initialize(connection, logger, connection_options, config)
super(connection, logger)
@config = config
super(connection, logger, config)
@quoted_column_names, @quoted_table_names = {}, {}

@visitor = Arel::Visitors::MySQL.new self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def connection_active?

# Initializes and connects a PostgreSQL adapter.
def initialize(connection, logger, connection_parameters, config)
super(connection, logger)
super(connection, logger, config)

@visitor = Arel::Visitors::PostgreSQL.new self
if self.class.type_cast_config_to_boolean(config.fetch(:prepared_statements) { true })
Expand All @@ -202,7 +202,7 @@ def initialize(connection, logger, connection_parameters, config)
@prepared_statements = false
end

@connection_parameters, @config = connection_parameters, config
@connection_parameters = connection_parameters

# @local_tz is initialized as nil to avoid warnings when connect tries to use it
@local_tz = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ def schema_creation # :nodoc:
end

def initialize(connection, logger, connection_options, config)
super(connection, logger)
super(connection, logger, config)

@active = nil
@statements = StatementPool.new(self.class.type_cast_config_to_integer(config.fetch(:statement_limit) { 1000 }))
@config = config

@visitor = Arel::Visitors::SQLite.new self
@quoted_column_names = {}
Expand Down

0 comments on commit 8c53b20

Please sign in to comment.