Class: DCI::MarshalledDB

Inherits:
GDBM
  • Object
show all
Defined in:
lib/dci/db.rb,
lib/dci/db.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ MarshalledDB

Returns a new instance of MarshalledDB.



9
10
11
# File 'lib/dci/db.rb', line 9

def initialize filename
	super(filename, Depot::OWRITER | Depot::OCREAT)
end

Instance Method Details

#[](k) ⇒ Object



17
18
19
20
# File 'lib/dci/db.rb', line 17

def [] k
  v = super k
  v ? Marshal.load(v) : nil
end

#[]=(k, v) ⇒ Object



13
14
15
# File 'lib/dci/db.rb', line 13

def []= k, v
  super k, Marshal.dump(v)
end

#eachObject



22
23
24
# File 'lib/dci/db.rb', line 22

def each
	super { |k,v| yield k, Marshal.load(v) }
end

#optimizeObject



44
45
46
# File 'lib/dci/db.rb', line 44

def optimize
	reorganize
end