about summary refs log tree commit
path: root/lib/metropolis/tdb/single.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-06 15:43:46 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-06 15:43:46 -0800
commit88fa90b7f039f62962cc8d11031446412b951be2 (patch)
tree04c2d961f6e3e41b069f074d7b93e1d91d8d716e /lib/metropolis/tdb/single.rb
parent74ca34be2d54809822447ff185d88d83fcd566ae (diff)
downloadmetropolis-88fa90b7f039f62962cc8d11031446412b951be2.tar.gz
allow easier, single-file options for TC and TDB
Most (other) users only need a single file, even though
my primary use of this is for multiple files.
Diffstat (limited to 'lib/metropolis/tdb/single.rb')
-rw-r--r--lib/metropolis/tdb/single.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/metropolis/tdb/single.rb b/lib/metropolis/tdb/single.rb
new file mode 100644
index 0000000..840b57a
--- /dev/null
+++ b/lib/metropolis/tdb/single.rb
@@ -0,0 +1,16 @@
+# -*- encoding: binary -*-
+module Metropolis::TDB::Single
+  def self.extended(obj)
+    obj.instance_eval do
+      @db = ::TDB.new(@uri.path, @tdb_opts)
+    end
+  end
+
+  def db(key, &block)
+    yield @db
+  end
+
+  def close!
+    @db.close
+  end
+end