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

- old
+ new

@@ -5,16 +5,18 @@ # CouchDB backend # @api public class Couch include Defaults + attr_reader :backend + # @param [Hash] options # @option options [String] :host ('http://127.0.0.1:5984') Couch host # @option options [String] :db ('moneta') Couch database + # @option options [::CouchRest] :backend Use existing backend instance def initialize(options = {}) - options[:db] ||= 'moneta' - options[:host] ||= '127.0.0.1:5984' - @db = CouchRest.new(options[:host]).database!(options[:db]) + @backend = options[:backend] || CouchRest.new(options[:host] || '127.0.0.1:5984') + @db = @backend.database!(options[:db] || 'moneta') end # (see Proxy#key?) def key?(key, options = {}) @db.get(key) != nil