Exceptions, which are raised after ensure will not be raised

This commit is contained in:
Denis Knauf 2010-03-21 00:39:45 +01:00
parent 9cae19fee4
commit f35c674923
5 changed files with 9 additions and 8 deletions

View file

@ -17,7 +17,7 @@ module SBDB
def unknown( *ps) Unknown.new *ps end
alias open_db unknown
def raise_barrier *ps, &e
def self.raise_barrier *ps, &e
e.call *ps
rescue Object
$stderr.puts [$!.class,$!,$!.backtrace].inspect

View file

@ -36,7 +36,7 @@ module SBDB
end
def self.new *ps
ret = obj = super *ps
ret = obj = super( *ps)
begin ret = yield obj
ensure obj.close
end if block_given?

View file

@ -50,8 +50,8 @@ module SBDB
ret = obj = super( *ps)
begin ret = exe.call obj
ensure
SBDB::raise_barrier obj.method(:sync)
SBDB::raise_barrier obj.method(:close)
SBDB::raise_barrier &obj.method(:sync)
SBDB::raise_barrier &obj.method(:close)
end if exe
ret
end
@ -133,7 +133,7 @@ module SBDB
Array = Recno
TYPES[DB::RECNO] = Recno
class Queue < Arrayisch
class Queue < DB
extend Arrayisch
def unshift txn = nil
@db.get _txn(txn), "\0\0\0\0", nil, Bdb::DB_CONSUME

View file

@ -75,7 +75,7 @@ module SBDB
def self.new *args
obj = ret = super( *args)
begin ret = yield obj
ensure SBDB::raise_barrier obj.method(:close)
ensure SBDB::raise_barrier &obj.method(:close)
end if block_given?
ret
end

View file

@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Denis Knauf"]
s.date = %q{2010-03-11}
s.date = %q{2010-03-21}
s.description = %q{Simple Ruby Berkeley DB wrapper library for bdb.}
s.email = %q{Denis.Knauf@gmail.com}
s.extra_rdoc_files = [
@ -17,7 +17,8 @@ Gem::Specification.new do |s|
"README.md"
]
s.files = [
"README.md",
"AUTHORS",
"README.md",
"VERSION",
"lib/sbdb.rb",
"lib/sbdb/cursor.rb",