Class: DCI::MarshalledDB
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
- #each ⇒ Object
-
#initialize(filename) ⇒ MarshalledDB
constructor
A new instance of MarshalledDB.
- #optimize ⇒ Object
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 |
#each ⇒ Object
22 23 24 |
# File 'lib/dci/db.rb', line 22 def each super { |k,v| yield k, Marshal.load(v) } end |
#optimize ⇒ Object
44 45 46 |
# File 'lib/dci/db.rb', line 44 def optimize reorganize end |