Checkpoint commit, start sketching out MDBX::Database.
FossilOrigin-Name: 92f55b2d6cc9652cb9cb67e69588ed0f4f155086a5a160aae68a1f22e9114314
This commit is contained in:
parent
6a7bfb722f
commit
37b8091690
11 changed files with 600 additions and 8 deletions
|
|
@ -10,9 +10,11 @@ require 'mdbx_ext'
|
|||
module MDBX
|
||||
|
||||
# The version of this gem.
|
||||
#
|
||||
# Note: the MDBX library version can be found in
|
||||
# the 'LIBRARY_VERSION' constant.
|
||||
#
|
||||
VERSION = '0.0.1'
|
||||
|
||||
end
|
||||
end # module MDBX
|
||||
|
||||
|
|
|
|||
43
lib/mdbx/database.rb
Normal file
43
lib/mdbx/database.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# -*- ruby -*-
|
||||
# vim: set nosta noet ts=4 sw=4 ft=ruby:
|
||||
# encoding: utf-8
|
||||
|
||||
require 'mdbx' unless defined?( MDBX )
|
||||
|
||||
|
||||
# TODO: rdoc
|
||||
#
|
||||
class MDBX::Database
|
||||
|
||||
|
||||
### Open an existing (or create a new) mdbx database at filesystem
|
||||
### +path+. In block form, the database is automatically closed.
|
||||
###
|
||||
### MDBX::Database.open( path ) -> db
|
||||
### MDBX::Database.open( path, options ) -> db
|
||||
### MDBX::Database.open( path, options ) do |db|
|
||||
### db[ 'key' ] #=> value
|
||||
### end
|
||||
###
|
||||
def self::open( *args, &block )
|
||||
db = new( *args )
|
||||
return db unless block_given?
|
||||
|
||||
begin
|
||||
yield db
|
||||
ensure
|
||||
db.close
|
||||
end
|
||||
end
|
||||
|
||||
# Only instantiate Database objects via #open.
|
||||
private_class_method :new
|
||||
|
||||
# The options used to instantiate this database.
|
||||
attr_reader :options
|
||||
|
||||
# The path on disk of the database.
|
||||
attr_reader :path
|
||||
|
||||
end # class MDBX::Database
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue