Module: RDBXML

Includes:
Dbxml
Defined in:
lib/rdbxml.rb

Overview

RDBXML – Pure-Ruby DB XML interface

This module provides Ruby-ish convenience functions for DBXML. See the unit tests for usage examples.

Class Method Summary collapse

Class Method Details

.env(dir, opts = {}) ⇒ Object

Creates a BDB environment with files stored in dir, with the following options:

:create

Create the environment if it doesn’t exist (default: true)

:lock

Use locking (default: true)

:log

Use logging (default: true)

:mpool

Use memory pool (default: true)

:txn

Use transactions (default: true)



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

def env( dir, opts = {} )
  opts = {
    :create => true,
    :lock => true,
    :log => true,
    :mpool => true,
    :txn => true,
  }.merge(opts)
  flags = {
    :create => Dbxml::DB_CREATE,
    :lock => Dbxml::DB_INIT_LOCK,
    :log => Dbxml::DB_INIT_LOG,
    :mpool => Dbxml::DB_INIT_MPOOL,
    :txn => Dbxml::DB_INIT_TXN,
  }.inject(0) { |flags, (key, val)|  flags|val  if opts[key] }

  env = DbEnv.new 0
  env.open dir, flags, 0
  env
end