Class: ActiveRecord::ConnectionAdapters::EmMysqlAdapter

Inherits:
MysqlAdapter
  • Object
show all
Defined in:
lib/active_record/connection_adapters/em_mysqlplus_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, logger, host_parameters, connection_parameters, config) ⇒ EmMysqlAdapter

Returns a new instance of EmMysqlAdapter.



10
11
12
13
14
15
# File 'lib/active_record/connection_adapters/em_mysqlplus_adapter.rb', line 10

def initialize(connection, logger, host_parameters, connection_parameters, config)
  @hostname = host_parameters[0]
  @port = host_parameters[1]
  @connect_parameters, @config = connection_parameters, config
  super(connection, logger, nil, config)
end

Instance Method Details

#connectObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_record/connection_adapters/em_mysqlplus_adapter.rb', line 17

def connect
  if EM.reactor_running?
    @connection = EventMachine::MySQL.new({
                                            :host => @hostname,
                                            :port => @port,
                                            :user => @config[:username],
                                            :database => @config[:database],
                                            :password => @config[:password],
                                            :socket   => @config[:socket]
    })

    configure_connection
    @connection
  else
    super
  end
end