Class: Timingapp::Database

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/timingapp/database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#open(path) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/timingapp/database.rb', line 13

def open(path)
  @path = path

  @connection = ActiveRecord::Base.establish_connection(
    adapter: "sqlite3",
    database: path,
    flags: SQLite3::Constants::Open::READONLY
  )
end