Class: DBI::BaseDriver

Inherits:
Base
  • Object
show all
Defined in:
lib/dbi/base_classes/driver.rb

Overview

Implements the basic functionality that constitutes a Driver

Drivers do not have a direct interface exposed to the user; these methods are mostly for DBD authors.

As with DBI::BaseDatabase, “DBD Required” and “DBD Optional” will be used to explain the same requirements.

Instance Method Summary collapse

Constructor Details

#initialize(dbi_version) ⇒ BaseDriver

Returns a new instance of BaseDriver.



12
13
14
15
16
17
18
# File 'lib/dbi/base_classes/driver.rb', line 12

def initialize(dbi_version)
    major, minor = dbi_version.split(".").collect { |x| x.to_i }
    dbi_major, dbi_minor = DBI::VERSION.split(".").collect { |x| x.to_i }
    unless major == dbi_major and minor == dbi_minor
        raise InterfaceError, "Wrong DBD API version used #{major}.#{minor} != dbi #{dbi_major}.#{dbi_minor}"
    end
end

Instance Method Details

#connect(dbname, user, auth, attr) ⇒ Object

Connect to the database. DBD Required.



21
22
23
# File 'lib/dbi/base_classes/driver.rb', line 21

def connect(dbname, user, auth, attr)
    raise NotImplementedError
end

#data_sourcesObject

Return the data sources available to this driver. Returns an empty array per default.



37
38
39
# File 'lib/dbi/base_classes/driver.rb', line 37

def data_sources
    []
end

#default_attributesObject

Default attributes to set on the DatabaseHandle.



31
32
33
# File 'lib/dbi/base_classes/driver.rb', line 31

def default_attributes
    {}
end

#default_userObject

Default u/p information in an array.



26
27
28
# File 'lib/dbi/base_classes/driver.rb', line 26

def default_user
    ['', '']
end

#disconnect_allObject

Disconnect all DatabaseHandles. DBD Required.



42
43
44
# File 'lib/dbi/base_classes/driver.rb', line 42

def disconnect_all
    raise NotImplementedError
end