Class: Purview::Connections::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/purview/connections/base.rb

Direct Known Subclasses

MSSQL, MySQL, PostgreSQL, SQLite

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/purview/connections/base.rb', line 8

def initialize(opts)
  @raw_connection = raw_connection_type.connect(opts)
end

Class Method Details

.connect(opts) ⇒ Object



4
5
6
# File 'lib/purview/connections/base.rb', line 4

def self.connect(opts)
  new(opts)
end

Instance Method Details

#disconnectObject



12
13
14
15
16
# File 'lib/purview/connections/base.rb', line 12

def disconnect
  raw_connection.disconnect
  @raw_connection = nil
  self
end

#execute(sql) ⇒ Object



18
19
20
# File 'lib/purview/connections/base.rb', line 18

def execute(sql)
  raw_connection.execute(sql)
end

#with_transactionObject



22
23
24
# File 'lib/purview/connections/base.rb', line 22

def with_transaction
  raw_connection.with_transaction { yield }
end