Module: OTP::JWT::ActiveRecord

Extended by:
ActiveSupport::Concern
Defined in:
lib/otp/jwt/active_record.rb

Overview

ActiveRecord

concern.

Instance Method Summary collapse

Instance Method Details

#to_jwt(claims = nil) ⇒ ActiveRecord::Base

Returns a [JWT] token for this record

Parameters:

  • claims (Hash) (defaults to: nil)

    extra claims to be included

Returns:

  • (ActiveRecord::Base)

    model



40
41
42
43
44
45
# File 'lib/otp/jwt/active_record.rb', line 40

def to_jwt(claims = nil)
  OTP::JWT::Token.sign(
    sub: self.send(self.class.primary_key),
    **(claims || {})
  )
end