lib/moneta/adapters/tdb.rb in moneta-0.7.9 vs lib/moneta/adapters/tdb.rb in moneta-0.7.10

- old
+ new

@@ -5,17 +5,21 @@ # TDB backend # @api public class TDB < Memory # @param [Hash] options # @option options [String] :file Database file - def initialize(options = {}) - raise ArgumentError, 'Option :file is required' unless file = options.delete(:file) - @hash = ::TDB.new(file, options) + # @option options [::TDB] :backend Use existing backend instance + def initialize(options) + @backend = options[:backend] || + begin + raise ArgumentError, 'Option :file is required' unless file = options.delete(:file) + ::TDB.new(file, options) + end end # (see Proxy#close) def close - @hash.close + @backend.close nil end end end end