Class: Sq::Dbsync::Database::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/sq/dbsync/database/connection.rb

Overview

Factory class to abstract selection of a decorator to faciliate databases other than MySQL.

Class Method Summary collapse

Class Method Details

.create(opts) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sq/dbsync/database/connection.rb', line 12

def self.create(opts)
  case opts[:brand]
  when 'mysql'
    db = Sq::Dbsync::Database::Mysql.new(Sequel.connect(opts))
    db.charset = opts[:charset] if opts[:charset]
    db
  when 'postgresql'
    Sq::Dbsync::Database::Postgres.new(Sequel.connect(opts))
  else
    raise "Unsupported database: #{opts.inspect}"
  end
end