summaryrefslogtreecommitdiff
path: root/lib/metropolis/tc/hdb/ex.rb
blob: d205a76da6be41f3f70325172e5681159bf6592e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Metropolis::TC::HDB::EX
  def self.extended(obj)
   obj.instance_eval do
      @wr_flags |= @rd_flags
      @rd_flags = nil
      @dbv.each { |(hdb, path)|
        hdb.open(path, @wr_flags) or ex!(:open, hdb)
      }
      @ex_dbv = @dbv.map { |(hdb,_)| hdb }
    end
  end

  def reader(key)
    yield @ex_dbv[multi_hash(key) % @nr_slots]
  end

  alias_method :writer, :reader
end