Class: Swift::Adapter::Sql Abstract

Inherits:
Swift::Adapter show all
Extended by:
Forwardable
Includes:
Migrations::InstanceMethods
Defined in:
lib/swift/adapter/sql.rb,
lib/swift/migrations.rb

Overview

This class is abstract.

Abstract SQL Adapter.

Direct Known Subclasses

Mysql, Postgres, Sqlite3

Constant Summary

Constants inherited from Swift::Adapter

EM

Instance Attribute Summary

Attributes inherited from Swift::Adapter

#db

Instance Method Summary collapse

Methods included from Migrations::InstanceMethods

#migrate!

Methods inherited from Swift::Adapter

#create, #delete, #execute, #get, #identity_map, #initialize, #log_command, #prepare, #trace, #trace?, #update

Constructor Details

This class inherits a constructor from Swift::Adapter

Instance Method Details

#fields(table) ⇒ Object


17
18
19
20
# File 'lib/swift/adapter/sql.rb', line 17

def fields table
  result = execute("select * from #{table} limit 0")
  Hash[result.fields.map(&:to_sym).zip(result.types)]
end

#tablesObject

Raises:

  • (NotImplementedError)

13
14
15
# File 'lib/swift/adapter/sql.rb', line 13

def tables
  raise NotImplementedError
end

#transaction(*args) ⇒ Object


22
23
24
# File 'lib/swift/adapter/sql.rb', line 22

def transaction *args
  db.transaction(*args) {|db| yield self}
end