module ActiveRecord::Jwt::Encoder

Public Class Methods

configure() { |configuration| ... } click to toggle source
# File lib/activerecord-jwt/encoder.rb, line 22
def self.configure(&block)
  yield(configuration)
end

Public Instance Methods

configuration() click to toggle source
# File lib/activerecord-jwt/encoder.rb, line 26
def configuration
  @_configuration ||= EncoderConfiguration.new
end
jwt() click to toggle source
# File lib/activerecord-jwt/encoder.rb, line 5
def jwt
  JWT.encode(payload, ActiveRecord::Jwt::Encoder.configuration.key, ActiveRecord::Jwt::Encoder.configuration.algorithm)
end

Private Instance Methods

payload() click to toggle source
# File lib/activerecord-jwt/encoder.rb, line 10
def payload
  {
    sub: self.send(ActiveRecord::Jwt::Encoder.configuration.sub),
    exp: Time.now.to_i + ActiveRecord::Jwt::Encoder.configuration.exp.to_i,
    iss: ActiveRecord::Jwt::Encoder.configuration.iss,
    aud: ActiveRecord::Jwt::Encoder.configuration.aud,
    iat: Time.now.to_i,
    class: self.class.to_s
  }
end