def replace_self(uri)
      # Reset dependent values
      instance_variables.each do |var|
        if instance_variable_defined?(var) && var != :@validation_deferred
          remove_instance_variable(var)
        end
      end

      @scheme = uri.scheme
      @user = uri.user
      @password = uri.password
      @host = uri.host
      @port = uri.port
      @path = uri.path
      @query = uri.query
      @fragment = uri.fragment
      return self
    end
def replace_self(uri)
      # Reset dependent values
      instance_variables.each do |var|
        if instance_variable_defined?(var) && var != :@validation_deferred
          remove_instance_variable(var)
        end
      end

      @scheme = uri.scheme
      @user = uri.user
      @password = uri.password
      @host = uri.host
      @port = uri.port
      @path = uri.path
      @query = uri.query
      @fragment = uri.fragment
      return self
    end
Replaces the internal state of self with the specified URI's state.
 Used in destructive operations to avoid massive code repetition.

 @param [Addressable::URI] uri The URI to replace <code>self</code> with.

 @return [Addressable::URI] <code>self</code>.