Module: BlackStack

Defined in:
lib/blackstack-db.rb,
lib/blackstack-db/crdb.rb,
lib/blackstack-db/postgresql.rb

Defined Under Namespace

Modules: CRDB, PostgreSQL

Constant Summary collapse

TYPE_POSTGRESQL =
0
TYPE_CRDB =
1
@@db_type =
nil

Class Method Summary collapse

Class Method Details

.connection_stringObject

db_type



20
21
22
23
24
25
26
27
28
# File 'lib/blackstack-db.rb', line 20

def self.connection_string
    if @@db_type == TYPE_POSTGRESQL
        return BlackStack::PostgreSQL.connection_string
    elsif @@db_type == TYPE_CRDB
        return BlackStack::CRDB.connection_string
    else
        raise "Unknown database type"
    end
end

.db_connectObject

connection_string



30
31
32
33
34
35
36
37
38
# File 'lib/blackstack-db.rb', line 30

def self.db_connect
    if @@db_type == TYPE_POSTGRESQL
        return BlackStack::PostgreSQL.connect
    elsif @@db_type == TYPE_CRDB
        return BlackStack::CRDB.connect
    else
        raise "Unknown database type"
    end
end

.db_test(l = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/blackstack-db.rb', line 40

def self.db_test(l=nil)
    if @@db_type == TYPE_POSTGRESQL
        return BlackStack::PostgreSQL.test(l)
    elsif @@db_type == TYPE_CRDB
        return BlackStack::CRDB.test(l)
    else
        raise "Unknown database type"
    end
end

.db_typeObject

set_db_type



16
17
18
# File 'lib/blackstack-db.rb', line 16

def self.db_type
    @@db_type
end

.set_db_type(n) ⇒ Object



12
13
14
# File 'lib/blackstack-db.rb', line 12

def self.set_db_type(n)
    @@db_type = n
end