Module: RDO

Defined in:
lib/rdo/driver.rb,
lib/rdo.rb,
lib/rdo/util.rb,
lib/rdo/result.rb,
lib/rdo/version.rb,
lib/rdo/exception.rb,
lib/rdo/statement.rb,
lib/rdo/connection.rb,
lib/rdo/colored_logger.rb,
lib/rdo/emulated_statement_executor.rb

Overview

RDO: Ruby Data Objects. Copyright © 2012 Chris Corbyn.

See LICENSE file for details.

Defined Under Namespace

Modules: Util Classes: ColoredLogger, Connection, Driver, EmulatedStatementExecutor, Exception, Result, Statement

Constant Summary collapse

VERSION =
"0.1.8"

Class Method Summary collapse

Class Method Details

.connect(uri, options = {}) ⇒ Connection Also known as: open

Establish a connection to the RDBMS. The connection will be returned open.

The needed driver must be loaded before calling this.

If a block is given, the connection is passed to the block and then closed at the end of the block, before this method finally returns the result of the block.

Parameters:

  • uri (Object)

    either a connection URI string, or an options Hash

  • options (Hash) (defaults to: {})

    if a URI is provided for the first argument, additional options may be specified here. These may override settings in the first argument.

Returns:

  • (Connection)

    a Connection for the required driver



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rdo.rb', line 41

def connect(uri, options = {})
  if block_given?
    begin
      c = Connection.new(uri, options)
      yield c
    ensure
      c.close unless c.nil?
    end
  else
    Connection.new(uri, options)
  end
end