Class: Squongo::Connection
- Inherits:
-
Object
- Object
- Squongo::Connection
- Defined in:
- lib/squongo/connection.rb
Constant Summary collapse
- WAL_QUERY =
'PRAGMA journal_mode=WAL;'
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #ensure_mode ⇒ Object
- #first_connection ⇒ Object
-
#initialize(path) ⇒ Connection
constructor
A new instance of Connection.
- #reconnect ⇒ Object
- #wal_mode ⇒ Object
Constructor Details
#initialize(path) ⇒ Connection
Returns a new instance of Connection.
10 11 12 13 14 |
# File 'lib/squongo/connection.rb', line 10 def initialize(path) @path = path @db = SQLite3::Database.open(path) ensure_mode end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
8 9 10 |
# File 'lib/squongo/connection.rb', line 8 def db @db end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/squongo/connection.rb', line 8 def path @path end |
Class Method Details
.connect(path) ⇒ Object
20 21 22 |
# File 'lib/squongo/connection.rb', line 20 def self.connect(path) self.new(path) end |
Instance Method Details
#ensure_mode ⇒ Object
24 25 26 27 |
# File 'lib/squongo/connection.rb', line 24 def ensure_mode return unless first_connection wal_mode end |
#first_connection ⇒ Object
33 34 35 |
# File 'lib/squongo/connection.rb', line 33 def first_connection !(File.exist?(path)) end |
#reconnect ⇒ Object
16 17 18 |
# File 'lib/squongo/connection.rb', line 16 def reconnect @db = SQLite3::Database.open(path) end |
#wal_mode ⇒ Object
29 30 31 |
# File 'lib/squongo/connection.rb', line 29 def wal_mode @db.execute WAL_QUERY end |