Class: Toro::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/toro/database.rb

Constant Summary collapse

SQL_DIRECTORY =
Pathname.new(File.expand_path('sql', File.dirname(__FILE__)))

Class Method Summary collapse

Class Method Details

.connectionObject



14
15
16
# File 'lib/toro/database.rb', line 14

def connection
  ActiveRecord::Base.connection
end

.downObject



10
11
12
# File 'lib/toro/database.rb', line 10

def down
  execute_file('down')
end

.query(sql, parameters = []) ⇒ Object



22
23
24
# File 'lib/toro/database.rb', line 22

def query(sql, parameters=[])
  raw_connection.exec(sql, parameters)
end

.raw_connectionObject



18
19
20
# File 'lib/toro/database.rb', line 18

def raw_connection
  connection.raw_connection
end

.upObject



6
7
8
# File 'lib/toro/database.rb', line 6

def up
  execute_file('up')
end

.with_connection(&block) ⇒ Object



26
27
28
# File 'lib/toro/database.rb', line 26

def with_connection(&block)
  ActiveRecord::Base.connection_pool.with_connection(&block)
end