SBDB::TYPES

This commit is contained in:
Denis Knauf 2010-02-06 11:50:52 +01:00
parent f3153fba9f
commit d723a228a0

View file

@ -2,6 +2,7 @@ require 'bdb'
require 'sbdb/cursor' require 'sbdb/cursor'
module SBDB module SBDB
TYPES = []
class DB class DB
UNKNOWN = Bdb::Db::UNKNOWN UNKNOWN = Bdb::Db::UNKNOWN
BTREE = Bdb::Db::BTREE BTREE = Bdb::Db::BTREE
@ -11,11 +12,6 @@ module SBDB
RDONLY = READLONY = Bdb::DB_RDONLY RDONLY = READLONY = Bdb::DB_RDONLY
CONSUME = Bdb::DB_CONSUME CONSUME = Bdb::DB_CONSUME
CONSUME_WAIT = Bdb::DB_CONSUME_WAIT CONSUME_WAIT = Bdb::DB_CONSUME_WAIT
TYPES = []
TYPES[BTREE] = Btree
TYPES[HASH] = Hash
TYPES[RECNO] = Recno
TYPES[QUEUE] = Queue
attr_reader :home attr_reader :home
include Enumerable include Enumerable
@ -95,12 +91,14 @@ module SBDB
super file, name, BTREE, *p, &e super file, name, BTREE, *p, &e
end end
end end
TYPES[DB::BTREE] = Btree
class Hash < DB class Hash < DB
def self.new file, name = nil, *p, &e def self.new file, name = nil, *p, &e
super file, name, HASH, *p, &e super file, name, HASH, *p, &e
end end
end end
TYPES[DB::HASH] = Hash
class Recno < DB class Recno < DB
def self.new file, name = nil, *p, &e def self.new file, name = nil, *p, &e
@ -116,6 +114,7 @@ module SBDB
end end
end end
Array = Recno Array = Recno
TYPES[DB::RECNO] = Recno
class Queue < DB class Queue < DB
def self.new file, name = nil, *p, &e def self.new file, name = nil, *p, &e
@ -134,4 +133,5 @@ module SBDB
get nil, nil, nil, Bdb::DB_CONSUME get nil, nil, nil, Bdb::DB_CONSUME
end end
end end
TYPES[DB::QUEUE] = Queue
end end