Method: Addressable::URI#password=

Defined in:
lib/addressable/uri.rb

#password=(new_password) ⇒ Object

Sets the password component for this URI.

Parameters:

  • new_password (String, #to_str)

    The new password component.



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/addressable/uri.rb', line 1025

def password=(new_password)
  if new_password && !new_password.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_password.class} into String."
  end
  @password = new_password ? new_password.to_str : nil

  # You can't have a nil user with a non-nil password
  if @password != nil
    self.user = EMPTY_STR if user.nil?
  end

  # Reset dependent values
  @userinfo = nil
  @normalized_userinfo = NONE
  @authority = nil
  @normalized_password = NONE
  remove_composite_values

  # Ensure we haven't created an invalid URI
  validate()
end