class ElasticAPM::Context::User

@api private

def self.infer(config, record)

def self.infer(config, record)
  return unless record
  new(
    id: safe_get(record, config.current_user_id_method)&.to_s,
    email: safe_get(record, config.current_user_email_method),
    username: safe_get(record, config.current_user_username_method)
  )
end

def any?

def any?
  !empty?
end

def empty?

def empty?
  !id && !email && !username
end

def initialize(id: nil, email: nil, username: nil)

def initialize(id: nil, email: nil, username: nil)
  @id = id
  @email = email
  @username = username
end

def safe_get(record, method_name)

def safe_get(record, method_name)
  record.respond_to?(method_name) ? record.send(method_name) : nil
end