class Database

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Attributes

path[R]

Public Instance Methods

connect_to(path) click to toggle source
# File lib/tmis/engine/database.rb, line 28
def connect_to(path)
  @path = path
  if ActiveRecord::Base.connected?
    ActiveRecord::Base.remove_connection
    connect path
  else
    connect path
  end
  self
end
connected?() click to toggle source
# File lib/tmis/engine/database.rb, line 39
def connected?
  ActiveRecord::Base.connected?
end
disconnect() click to toggle source
# File lib/tmis/engine/database.rb, line 43
def disconnect
  ActiveRecord::Base.remove_connection; self
end
transaction(&block) click to toggle source
# File lib/tmis/engine/database.rb, line 47
def transaction(&block)
  ActiveRecord::Base.transaction(&block); self
end

Private Instance Methods

connect(path) click to toggle source
# File lib/tmis/engine/database.rb, line 52
def connect(path)
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: path)
  ActiveRecord::Base.timestamped_migrations = false
  ActiveRecord::Migrator.up (File.dirname(__FILE__) << '/migrations')
  self
end