Class: DBConnection

Inherits:
Object show all
Defined in:
lib/activeleopard/db_connection.rb

Class Method Summary collapse

Class Method Details

.async_exec(*args) ⇒ Object



16
17
18
19
# File 'lib/activeleopard/db_connection.rb', line 16

def self.async_exec(*args)
  print_query(*args)
  instance.send_query(*args)
end

.execute(*args) ⇒ Object



11
12
13
14
# File 'lib/activeleopard/db_connection.rb', line 11

def self.execute(*args)
  print_query(*args)
  instance.exec(*args)
end

.get_first_row(*args) ⇒ Object



21
22
23
24
# File 'lib/activeleopard/db_connection.rb', line 21

def self.get_first_row(*args)
  print_query(*args)
  instance.exec(*args).first
end

.instanceObject



5
6
7
8
9
# File 'lib/activeleopard/db_connection.rb', line 5

def self.instance
  open if @db.nil?

  @db
end

.run_migrationsObject



26
27
28
29
30
31
32
33
34
# File 'lib/activeleopard/db_connection.rb', line 26

def self.run_migrations
  ensure_migrations_table!
  migrations = Dir.entries("db/migrations").reject { |fname| fname.start_with?('.') }
  migrations.sort_by! { |fname| Integer(fname[0..1]) }

  migrations.each do |file_name|
    run_migration_file(file_name)
  end
end