class Toro::Database

Constants

SQL_DIRECTORY

Public Class Methods

connection() click to toggle source
# File lib/toro/database.rb, line 16
def connection
  ActiveRecord::Base.connection
end
down() click to toggle source
# 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=[]) click to toggle source
# File lib/toro/database.rb, line 24
def query(sql, parameters=[])
  raw_connection.exec(sql, parameters)
end
raw_connection() click to toggle source
# File lib/toro/database.rb, line 20
def raw_connection
  connection.raw_connection
end
up() click to toggle source
# 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) click to toggle source
# File lib/toro/database.rb, line 28
def with_connection(&block)
  ActiveRecord::Base.connection_pool.with_connection(&block)
end

Private Class Methods

execute_file(file_name) click to toggle source
# File lib/toro/database.rb, line 34
def execute_file(file_name)
  file_path = SQL_DIRECTORY.join("#{file_name}.sql")
  connection.execute(File.read(file_path))
end