Class: Shiba::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/shiba/connection.rb,
lib/shiba/connection/mysql.rb,
lib/shiba/connection/postgres.rb

Defined Under Namespace

Classes: Mysql, Postgres

Class Method Summary collapse

Class Method Details

.build(hash) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/shiba/connection.rb', line 3

def self.build(hash)
  server_type = hash['server']
  if !server_type
    port = hash['port'].to_i
    if port == 3306
      server_type = 'mysql'
    elsif port == 5432
      server_type = 'postgres'
    else
      raise "couldn't determine server type!  please pass --server"
    end
  end

  if server_type == 'mysql'
    require 'shiba/connection/mysql'
    Shiba::Connection::Mysql.new(hash)
  else
    require 'shiba/connection/postgres'
    Shiba::Connection::Postgres.new(hash)
  end
end