Env#[]: args should be the same like DB::initialize, now
This commit is contained in:
parent
da7476fe70
commit
a9d9aa3664
2 changed files with 12 additions and 6 deletions
|
@ -63,6 +63,14 @@ module SBDB
|
|||
txn && t.bdb_object
|
||||
end
|
||||
|
||||
# Arguments:
|
||||
# * file
|
||||
# * name
|
||||
# * type
|
||||
# * flags
|
||||
# * mode
|
||||
# * env
|
||||
# or: **file**, **opts**. *opts* must be a *::Hash* with keys like above, excluded *file*.
|
||||
def initialize file, *args
|
||||
opts = ::Hash === args.last ? args.pop : {}
|
||||
opts = {:name => args[0], :type => args[1], :flags => args[2], :mode => args[3], :env => args[4]}.update opts
|
||||
|
|
|
@ -106,12 +106,10 @@ module SBDB
|
|||
# If you use this, never use close. It's possible somebody else use it too.
|
||||
# The Databases, which are opened, will close, if the Environment will close.
|
||||
def [] file, *ps, &exe
|
||||
ps.push ::Hash.new unless ::Hash === ps.last
|
||||
ps.last[:env] = self
|
||||
name, flg, type =
|
||||
String === ps[0] ? ps[0] : ps.last[:name],
|
||||
Fixnum === ps[2] ? ps[2] : ps.last[:flags],
|
||||
Fixnum === ps[1] ? ps[1] : ps.last[:type]
|
||||
opts = ::Hash === ps.last ? ps.pop : {}
|
||||
opts[:env] = self
|
||||
name, type, flg = ps[0] || opts[:name], ps[1] || opts[:type], ps[2] || opts[:flags]
|
||||
ps.push opts
|
||||
@dbs[ [file, name, flg | CREATE]] ||= (type || SBDB::Unknown).new file, *ps, &exe
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue