require 'rubygems'
require 'relaxdb'

module Merb
  module RelaxDB
    
    class << self
      
      def connect
        set_database
        begin
          ::RelaxDB::Database.std_db.get
          Merb.logger.info "RelaxDB connected to CouchDB #{config_to_url}"
        rescue
          puts "RelaxDB could not connect to CouchDB at #{config_to_url}. Exiting..."
          Merb.logger.error "RelaxDB could not connect to CouchDB at #{config_to_url}. Exiting..."
          exit(1)
        end
      end
      
      def set_database
        config_file = Merb.root / "config" / "couchdb.yml"
        full_config = Erubis.load_yaml_file(config_file)
        @config = full_config[Merb.environment.to_sym]
        ::RelaxDB::Database.set_std_db(@config)
      end
      
      def config_to_url
        "http://#{@config[:host]}:#{@config[:port]}/#{@config[:db]}"
      end
            
    end
    
  end
end

require 'rubygems'
require 'relaxdb'

module Merb
  module RelaxDB
    
    class << self
      
      def connect
        set_database
        begin
          ::RelaxDB.db.get
          Merb.logger.info "RelaxDB connected to CouchDB #{::RelaxDB.db.url}"
        rescue
          puts "RelaxDB could not connect to CouchDB at #{::RelaxDB.db.url} Exiting..."
          Merb.logger.error "RelaxDB could not connect to CouchDB at #{::RelaxDB.db.url} Exiting..."
          exit(1)
        end
      end
      
      def set_database
        config_file = Merb.root / "config" / "couchdb.yml"
        full_config = Erubis.load_yaml_file(config_file)
        config = full_config[Merb.environment.to_sym]
        ::RelaxDB.configure(config)
      end
                  
    end
    
  end
end

Update to reflect latest version of RelaxDB
Update to reflect latest version of RelaxDB
