Class: HTTP::CookieJar::MozillaStore::Database
- Inherits:
-
Object
- Object
- HTTP::CookieJar::MozillaStore::Database
- Defined in:
- lib/http/cookie_jar/mozilla_store.rb
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #create_function(*args, &block) ⇒ Object
- #execute(*args, &block) ⇒ Object
-
#initialize(file) ⇒ Database
constructor
A new instance of Database.
- #prepare(sql) ⇒ Object
Constructor Details
#initialize(file) ⇒ Database
Returns a new instance of Database.
41 42 43 44 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 41 def initialize(file) @db = SQLite3::Database.new(file, results_as_hash: true) @stmts = [] end |
Instance Method Details
#close ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 52 def close return self if closed? @stmts.reject! { |st| st.closed? || st.close } @db.close end |
#closed? ⇒ Boolean
60 61 62 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 60 def closed? @db.closed? end |
#create_function(*args, &block) ⇒ Object
68 69 70 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 68 def create_function(*args, &block) @db.create_function(*args, &block) end |
#execute(*args, &block) ⇒ Object
64 65 66 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 64 def execute(*args, &block) @db.execute(*args, &block) end |
#prepare(sql) ⇒ Object
46 47 48 49 50 |
# File 'lib/http/cookie_jar/mozilla_store.rb', line 46 def prepare(sql) st = @db.prepare(sql) @stmts << st if st.is_a?(SQLite3::Statement) st end |