Module: Rhubarb::Persistence

Defined in:
lib/rhubarb/classmixins.rb,
lib/rhubarb/persistence.rb

Overview

Forward declaration

Defined Under Namespace

Modules: EschewPreparedStatements, UsePreparedStatements Classes: DbCollection

Class Method Summary collapse

Class Method Details

.close(which = :default) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/rhubarb/persistence.rb', line 82

def self.close(which=:default)
  current_db = dbs[which]
  if current_db
    dbs.delete(which)
    current_db.stmts.values.each {|pstmt| pstmt.close }
    current_db.close
  end
end

.dbObject



91
92
93
# File 'lib/rhubarb/persistence.rb', line 91

def self.db
  dbs[:default]
end

.db=(d) ⇒ Object



95
96
97
# File 'lib/rhubarb/persistence.rb', line 95

def self.db=(d)
  dbs[:default] = d
end

.dbsObject



99
100
101
# File 'lib/rhubarb/persistence.rb', line 99

def self.dbs
  @dbs
end

.open(filename, which = :default, usePrepared = true) ⇒ Object



77
78
79
80
# File 'lib/rhubarb/persistence.rb', line 77

def self.open(filename, which=:default, usePrepared=true)
  dbs.use_prepared_stmts = usePrepared
  dbs[which] = SQLite3::Database.new(filename)
end

.prepared_okObject



68
69
70
# File 'lib/rhubarb/persistence.rb', line 68

def self.prepared_ok
  !!sqlite_13
end

.sqlite_13Object



72
73
74
75
# File 'lib/rhubarb/persistence.rb', line 72

def self.sqlite_13
  result = (SQLite3.constants.include?("VERSION") || SQLite3.constants.include?(:VERSION)) && SQLite3::VERSION =~ /1\.3\.[0-9]+/
  !!result
end