Class: JWT::Encode

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

Overview

Encoding logic for JWT

Constant Summary collapse

ALG_NONE =
'none'.freeze
ALG_KEY =
'alg'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Encode

Returns a new instance of Encode.



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

def initialize(options)
  @payload   = options[:payload]
  @key       = options[:key]
  @algorithm = options[:algorithm]
  @headers   = options[:headers].each_with_object({}) { |(key, value), headers| headers[key.to_s] = value }
end

Instance Method Details

#segmentsObject



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

def segments
  @segments ||= combine(encoded_header_and_payload, encoded_signature)
end