Class: JWT::Encode

Inherits:
Object
  • Object
show all
Defined in:
lib/jwt/encode.rb

Overview

Encoding logic for JWT

Constant Summary collapse

ALG_KEY =
'alg'

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Encode

Returns a new instance of Encode.



12
13
14
15
16
17
18
# File 'lib/jwt/encode.rb', line 12

def initialize(options)
  @payload          = options[:payload]
  @key              = options[:key]
  @algorithm        = resolve_algorithm(options[:algorithm])
  @headers          = options[:headers].transform_keys(&:to_s)
  @headers[ALG_KEY] = @algorithm.alg
end

Instance Method Details

#segmentsObject



20
21
22
23
# File 'lib/jwt/encode.rb', line 20

def segments
  validate_claims!
  combine(encoded_header_and_payload, encoded_signature)
end