Checkpoint commit.
Fleshing out collections, automatic serialization of values. Stringify all keys. FossilOrigin-Name: 8bb5e27eacd18bc34b60309a03cdce31921f790c821dab89bf12cd9bfc19825d
This commit is contained in:
parent
9f1388a8de
commit
d92ba7c5eb
3 changed files with 154 additions and 24 deletions
|
|
@ -21,15 +21,22 @@ class MDBX::Database
|
|||
###
|
||||
def self::open( *args, &block )
|
||||
db = new( *args )
|
||||
return db unless block_given?
|
||||
|
||||
begin
|
||||
yield db
|
||||
ensure
|
||||
db.close
|
||||
db.serializer = ->( v ) { Marshal.dump( v ) }
|
||||
db.deserializer = ->( v ) { Marshal.load( v ) }
|
||||
|
||||
if block_given?
|
||||
begin
|
||||
yield db
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
|
||||
return db
|
||||
end
|
||||
|
||||
|
||||
# Only instantiate Database objects via #open.
|
||||
private_class_method :new
|
||||
|
||||
|
|
@ -39,5 +46,11 @@ class MDBX::Database
|
|||
# The path on disk of the database.
|
||||
attr_reader :path
|
||||
|
||||
# A Proc for automatically serializing values.
|
||||
attr_accessor :serializer
|
||||
|
||||
# A Proc for automatically deserializing values.
|
||||
attr_accessor :deserializer
|
||||
|
||||
end # class MDBX::Database
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue