Class: Litedb::Connection

Inherits:
SQLite3::Database
  • Object
show all
Defined in:
lib/litedb/connection.rb

Constant Summary collapse

DEFAULT_FILE =
":memory:"
DEFAULT_OPTIONS =
{
  synchronous: :NORMAL,
  mmap_size: 32 * 1024, # 32 kilobytes
  journal_size_limit: 64 * 1024 * 1024 # 64 megabytes
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil, options = {}, zvfs = nil) ⇒ Connection

Returns a new instance of Connection.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/litedb/connection.rb', line 17

def initialize(file = nil, options = {}, zvfs = nil)
  @scheduler = Litescheduler.instance
  file ||= DEFAULT_FILE
  options = options.transform_keys { |key|
    begin
      key.to_sym
    rescue
      key
    end
  }
  @config = DEFAULT_OPTIONS.merge(options)

  super(file, @config, zvfs)

  set_pragmas
  run_migrations
  prepare_statements
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



15
16
17
# File 'lib/litedb/connection.rb', line 15

def config
  @config
end

Instance Method Details

#run_statement(statement, *args) ⇒ Object



36
37
38
# File 'lib/litedb/connection.rb', line 36

def run_statement(statement, *args)
  statements[statement].execute!(*args)
end