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



16
17
18
# File 'lib/toro/database.rb', line 16

def connection
  ActiveRecord::Base.connection
end

.downObject



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

def down
  connection.disable_extension :hstore if ActiveRecord::VERSION::MAJOR >= 4
  execute_file('down')
end

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



24
25
26
# File 'lib/toro/database.rb', line 24

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

.raw_connectionObject



20
21
22
# File 'lib/toro/database.rb', line 20

def raw_connection
  connection.raw_connection
end

.upObject



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

def up
  connection.enable_extension :hstore if ActiveRecord::VERSION::MAJOR >= 4
  execute_file('up')
end

.with_connection(&block) ⇒ Object



28
29
30
# File 'lib/toro/database.rb', line 28

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