Class: T2Server::HttpCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/t2-server/net/credentials.rb

Overview

This class serves as a base class for concrete HTTP credential systems.

Instances of this class cannot be used to authenticate a connection; please use HttpBasic instead.

Direct Known Subclasses

HttpBasic

Constant Summary collapse

@@to_s =

Used within #inspect, below to help override the built in version.

Kernel.instance_method(:to_s)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ HttpCredentials

:stopdoc: Create a set of credentials with the supplied username and password.



49
50
51
52
# File 'lib/t2-server/net/credentials.rb', line 49

def initialize(username, password)
  @username = username
  @password = password
end

Instance Attribute Details

#usernameObject (readonly)

The username held by these credentials.



45
46
47
# File 'lib/t2-server/net/credentials.rb', line 45

def username
  @username
end

Instance Method Details

#inspectObject

:call-seq:

inspect -> string

Override the Kernel#inspect method so that the password is not exposed when it is called.



72
73
74
# File 'lib/t2-server/net/credentials.rb', line 72

def inspect
  @@to_s.bind(self).call.sub!(/>\z/) {" Username:#{self}>"}
end

#to_sObject

:call-seq:

to_s -> string

Return a String representation of these credentials. Just the username is returned; the password is kept hidden.



60
61
62
# File 'lib/t2-server/net/credentials.rb', line 60

def to_s
  @username
end