Sha256: 0d1cc6e75748c94323ee95f63613a5e05950d937a2b66d77bba0b0e18b78e672
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
class Baza::Cloner def self.from_active_record_connection(connection) if connection.class.name.include?("Mysql2Adapter") connection = connection.instance_variable_get(:@connection) config = connection.instance_variable_get(:@query_options) config ||= connection.instance_variable_get(:@config) db_args = { type: :mysql2, host: config[:host], user: config[:username], pass: config[:password], db: config[:database] } Baza::Db.new(db_args) elsif connection.class.name.include?("MysqlAdapter") connection = connection.instance_variable_get(:@connection) connection = connection.instance_variable_get(:@connection) if RUBY_PLATFORM == "java" db_args = { type: :mysql, conn: connection } Baza::Db.new(db_args) elsif connection.class.name.include?("PostgreSQLAdapter") connection = connection.instance_variable_get(:@connection) connection = connection.instance_variable_get(:@connection) if RUBY_PLATFORM == "java" db_args = { type: :pg, conn: connection } Baza::Db.new(db_args) else raise "Unsupported adapter: #{connection.class.name}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
baza-0.0.38 | lib/baza/cloner.rb |
baza-0.0.37 | lib/baza/cloner.rb |
baza-0.0.36 | lib/baza/cloner.rb |