Class: MultiAuthSample::BasicAuthCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_auth_sample/http/auth/basic_auth.rb

Overview

Data class for BasicAuthCredentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, password:) ⇒ BasicAuthCredentials

Returns a new instance of BasicAuthCredentials.

Raises:

  • (ArgumentError)


34
35
36
37
38
39
40
# File 'lib/multi_auth_sample/http/auth/basic_auth.rb', line 34

def initialize(username:, password:)
  raise ArgumentError, 'username cannot be nil' if username.nil?
  raise ArgumentError, 'password cannot be nil' if password.nil?

  @username = username
  @password = password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



32
33
34
# File 'lib/multi_auth_sample/http/auth/basic_auth.rb', line 32

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



32
33
34
# File 'lib/multi_auth_sample/http/auth/basic_auth.rb', line 32

def username
  @username
end

Instance Method Details

#clone_with(username: nil, password: nil) ⇒ Object



42
43
44
45
46
47
# File 'lib/multi_auth_sample/http/auth/basic_auth.rb', line 42

def clone_with(username: nil, password: nil)
  username ||= self.username
  password ||= self.password

  BasicAuthCredentials.new(username: username, password: password)
end