Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/mysqlspatial_adapter.rb
Overview
ActiveRecord looks for the mysqlspatial_connection factory method in this class.
Class Method Summary collapse
-
.mysqlspatial_connection(config_) ⇒ Object
Create a mysqlspatial connection adapter.
Class Method Details
.mysqlspatial_connection(config_) ⇒ Object
Create a mysqlspatial connection adapter.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/active_record/connection_adapters/mysqlspatial_adapter.rb', line 55 def self.mysqlspatial_connection(config_) unless defined?(::Mysql) begin require 'mysql' rescue ::LoadError raise "!!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql'" end unless defined?(::Mysql::Result) && ::Mysql::Result.method_defined?(:each_hash) raise "!!! Outdated mysql gem. Upgrade to 2.8.1 or later. In your Gemfile: gem 'mysql', '2.8.1'. Or use gem 'mysql2'" end end config_ = config_.symbolize_keys mysql_ = ::Mysql.init mysql_.ssl_set(config_[:sslkey], config_[:sslcert], config_[:sslca], config_[:sslcapath], config_[:sslcipher]) if config_[:sslca] || config_[:sslkey] default_flags_ = ::Mysql.const_defined?(:CLIENT_MULTI_RESULTS) ? ::Mysql::CLIENT_MULTI_RESULTS : 0 default_flags_ |= ::Mysql::CLIENT_FOUND_ROWS if ::Mysql.const_defined?(:CLIENT_FOUND_ROWS) = [config_[:host], config_[:username] ? config_[:username].to_s : 'root', config_[:password].to_s, config_[:database], config_[:port], config_[:socket], default_flags_] ::ActiveRecord::ConnectionAdapters::MysqlSpatialAdapter::MainAdapter.new(mysql_, logger, , config_) end |