class JWT::Encode

The Encode class is responsible for encoding JWT tokens.

def initialize(options)

Options Hash: (**options)
  • :algorithm (String) -- the algorithm used to sign the JWT token.
  • :key (String) -- the key used to sign the JWT token.
  • :headers (Hash) -- the headers of the JWT token.
  • :payload (Hash) -- the payload of the JWT token.

Parameters:
  • options (Hash) -- the options for encoding the JWT token.
def initialize(options)
  @token     = Token.new(payload: options[:payload], header: options[:headers])
  @key       = options[:key]
  @algorithm = options[:algorithm]
end

def segments

Returns:
  • (String) - the encoded JWT token.
def segments
  @token.verify_claims!(:numeric)
  @token.sign!(algorithm: @algorithm, key: @key)
  @token.jwt
end