Class: Simple::SQL::Connection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
ConnectionAdapter
Defined in:
lib/simple/sql/connection.rb

Overview

A Connection object.

A Connection object is built around a raw connection (as created from the pg ruby gem).

It includes the ConnectionAdapter, which implements ask, all, + friends, and also includes a quiet simplistic Transaction implementation

Direct Known Subclasses

ActiveRecordConnection, RawConnection

Defined Under Namespace

Classes: ActiveRecordConnection, RawConnection

Constant Summary

Constants included from ConnectionAdapter

Simple::SQL::ConnectionAdapter::Logging, Simple::SQL::ConnectionAdapter::Scope

Class Method Summary collapse

Methods included from ConnectionAdapter

#all, #ask, #each, #exec, #locked, #print, #resolve_type

Class Method Details

.create(database_url = :auto) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/simple/sql/connection.rb', line 11

def self.create(database_url = :auto)
  case database_url
  when :auto
    if defined?(::ActiveRecord)
      ActiveRecordConnection.new
    else
      RawConnection.new Simple::SQL::Config.determine_url
    end
  else
    RawConnection.new database_url
  end
end