Class: Net::HTTP::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/net/http/signature.rb,
lib/net/http/signature/signer.rb,
lib/net/http/signature/request.rb,
lib/net/http/signature/version.rb

Defined Under Namespace

Classes: Request, Signer

Constant Summary collapse

HEADER =
"Signature"
VERSION =
"1.0.1"

Instance Method Summary collapse

Constructor Details

#initialize(key:, signer:) ⇒ Signature

Returns a new instance of Signature.



14
15
16
17
# File 'lib/net/http/signature.rb', line 14

def initialize(key:, signer:)
  @key = key
  @signer = signer
end

Instance Method Details

#to_hObject



27
28
29
30
31
# File 'lib/net/http/signature.rb', line 27

def to_h
  {
    HEADER => to_s
  }
end

#to_sObject



23
24
25
# File 'lib/net/http/signature.rb', line 23

def to_s
  "key=#{key} algorithm=#{algorithm} token=#{signer}"
end

#valid?(string) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/net/http/signature.rb', line 19

def valid?(string)
  to_s.strip == string.strip
end