Module: Gonzui::DBM

Defined in:
lib/gonzui/dbm.rb

Class Method Summary collapse

Class Method Details

.open(config, read_only = false) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gonzui/dbm.rb', line 19

def open(config, read_only = false)
  File.mkpath(config.db_directory) unless read_only

  dbm_class = BDBDBM # to be pluggable
  dbm = dbm_class.new(config, read_only)
  if block_given?
    begin
      yield(dbm)
    ensure
      dbm.close
    end
  else
    return dbm
  end
end