Class: Litedb

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

Defined Under Namespace

Classes: Error

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
VERSION =
"0.2.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Litedb.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/litedb.rb', line 20

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.



18
19
20
# File 'lib/litedb.rb', line 18

def config
  @config
end

Instance Method Details

#run_statement(statement, *args) ⇒ Object



39
40
41
# File 'lib/litedb.rb', line 39

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