You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: session.rb
    path of file: ./repos/stealth/lib/stealth
    
    the code of the file until where you have to start completion: # coding: utf-8
# frozen_string_literal: true

module Stealth
  class Session

    include Stealth::Redis

    SLUG_SEPARATOR = '->'

    attr_reader :flow, :state, :id, :type
    attr_accessor :session

    # Session types:
    #   - :primary
    #   - :previous
    #   - :back_to
    def initialize(id: nil, type: :primary)
      @id = id
      @type = type
    
      def store_current_to_previous(existing_session:)
        # Prevent previous_session from becoming current_session
        if session == existing_session
          Stealth::Logger.l(
            topic: "previous_session",
            message: "User #{id}: skipping setting to #{session}"\
                     ' because it is the same as current_session'
          )
        else
          Stealth::Logger.l(
            topic: "previous_session",
            message: "User #{id}: setting to #{existing_session}"
          )

          persist_key(
            key: previous_session_key,
            value: existing_session
          )
        end