require 'delegate'

# the ConnectionProxy sits between user-code and a real connection and says "I expect to be on this database"
# for each call to the connection.  upon executing a statement, the connection will switch to that database.
module ActiveRecordHostPool
  class ConnectionProxy < Delegator
    def initialize(cx, database)
      @cx = cx
      @database = database
    end

    def __getobj__
      @cx._host_pool_current_database = @database
      @cx
    end

    def unproxied
      @cx
    end

    def self.class_eval(*args, &block)
      @cx.class.class_eval(*args, &block)
    end
  end
end



require 'delegate'

# the ConnectionProxy sits between user-code and a real connection and says "I expect to be on this database"
# for each call to the connection.  upon executing a statement, the connection will switch to that database.
module ActiveRecordHostPool
  class ConnectionProxy < Delegator
    def initialize(cx, database)
      @cx = cx
      @database = database
    end

    def __getobj__
      @cx._host_pool_current_database = @database
      @cx
    end

    def unproxied
      @cx
    end

    # this helps along folks who want to muck around with our delegatee's methods
    def class
      @cx.class
    end
  end
end



Revert "testing a different way of allowing more monkey patches"
Revert "testing a different way of allowing more monkey patches"

This reverts commit 3143ef62f79848ec05db98b705f4edef8a146a4a.
