Class: HTTP::TokenAuth::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/http/token_auth/credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, coverage: nil, nonce: nil, auth: nil, timestamp: nil) ⇒ Credentials

Returns a new instance of Credentials.



9
10
11
12
13
14
15
16
# File 'lib/http/token_auth/credentials.rb', line 9

def initialize(token:, coverage: nil, nonce: nil, auth: nil, timestamp: nil)
  @token = token
  @coverage = coverage.nil? ? :none : coverage
  @nonce = nonce
  @auth = auth
  @timestamp = timestamp
  validate_itself
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



7
8
9
# File 'lib/http/token_auth/credentials.rb', line 7

def auth
  @auth
end

#coverageObject (readonly)

Returns the value of attribute coverage.



7
8
9
# File 'lib/http/token_auth/credentials.rb', line 7

def coverage
  @coverage
end

#nonceObject (readonly)

Returns the value of attribute nonce.



7
8
9
# File 'lib/http/token_auth/credentials.rb', line 7

def nonce
  @nonce
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/http/token_auth/credentials.rb', line 7

def timestamp
  @timestamp
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/http/token_auth/credentials.rb', line 7

def token
  @token
end

Instance Method Details

#to_headerObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/http/token_auth/credentials.rb', line 18

def to_header
  attributes = []
  attributes << %(token="#{@token}")
  unless coverage == :none
    attributes << %(coverage="#{coverage_name}")
    attributes << %(nonce="#{@nonce}")
    attributes << %(auth="#{@auth}")
    attributes << %(timestamp="#{@timestamp}")
  end
  "Token #{attributes.join(', ')}"
end