Class: ActiveRecord::Base

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

Overview

ActiveRecord looks for the mysql2spatial_connection factory method in this class.

Class Method Summary collapse

Class Method Details

.mysql2spatial_connection(config_) ⇒ Object

Create a mysql2spatial connection adapter.



48
49
50
51
52
53
54
55
56
# File 'lib/active_record/connection_adapters/mysql2spatial_adapter.rb', line 48

def self.mysql2spatial_connection(config_)
  config_[:username] = 'root' if config_[:username].nil?
  if ::Mysql2::Client.const_defined?(:FOUND_ROWS)
    config_[:flags] = ::Mysql2::Client::FOUND_ROWS
  end
  client_ = ::Mysql2::Client.new(config_.symbolize_keys)
  options_ = [config_[:host], config_[:username], config_[:password], config_[:database], config_[:port], config_[:socket], 0]
  ::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::MainAdapter.new(client_, logger, options_, config_)
end