Class: Tetrahedron::Databases::SQLite3

Inherits:
Tetrahedron::Database::Provider show all
Defined in:
lib/tetrahedron/databases/sqlite3.rb

Defined Under Namespace

Classes: Configuration

Instance Method Summary collapse

Constructor Details

#initialize(&configurator) ⇒ SQLite3

Returns a new instance of SQLite3.



8
9
10
11
12
# File 'lib/tetrahedron/databases/sqlite3.rb', line 8

def initialize(&configurator)
  @configuration = Configuration.new
  # TODO(mtwilliams): Invoke such that users don't have to prepend |self|.
  @configuration.instance_eval(&configurator) if block_given?
end

Instance Method Details

#connectObject



18
19
20
21
22
23
# File 'lib/tetrahedron/databases/sqlite3.rb', line 18

def connect
  # If no path was specified, default to a transient in-memory database.
  puts "Connecting to SQlite3 database at #{@configuration.path}"
  @connection = Sequel.sqlite(@configuration.path)
  true
end

#connectionObject



14
15
16
# File 'lib/tetrahedron/databases/sqlite3.rb', line 14

def connection
  @connection
end

#disconnectObject



25
26
27
28
29
# File 'lib/tetrahedron/databases/sqlite3.rb', line 25

def disconnect
  @connection.disconnect if @connection
  @connection = nil
  true
end