bradrobertson/apartment

View on GitHub
lib/apartment/adapters/mysql2_adapter.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Apartment

  module Database

    def self.mysql2_adapter(config)
      Adapters::Mysql2Adapter.new config
    end
  end

  module Adapters

    class Mysql2Adapter < AbstractAdapter

    protected

      #   Connect to new database
      #   Abstract adapter will catch generic ActiveRecord error
      #   Catch specific adapter errors here
      #
      #   @param {String} database Database name
      #
      def connect_to_new(database)
        super
      rescue Mysql2::Error
        raise DatabaseNotFound, "Cannot find database #{environmentify(database)}"
      end
    end
  end
end