Class: T2Server::HttpCredentials
- Inherits:
-
Object
- Object
- T2Server::HttpCredentials
- 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
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
-
#username ⇒ Object
readonly
The username held by these credentials.
Instance Method Summary collapse
-
#initialize(username, password) ⇒ HttpCredentials
constructor
:stopdoc: Create a set of credentials with the supplied username and password.
-
#inspect ⇒ Object
:call-seq: inspect -> string.
-
#to_s ⇒ Object
:call-seq: to_s -> string.
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
#username ⇒ Object (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
#inspect ⇒ Object
: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_s ⇒ Object
: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 |