Sha256: 2b6eede0265cd8db34734e6304daf8c7f160060b57f72dc57d151d2ef7e1f67c

Contents?: true

Size: 622 Bytes

Versions: 5

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module DuodealerApp
  class InMemorySessionStore
    class EnvironmentError < StandardError; end

    def self.retrieve(id)
      repo[id]
    end

    def self.store(session, *args)
      id = SecureRandom.uuid
      repo[id] = session
      id
    end

    def self.clear
      @@repo = nil
    end

    def self.repo
      if Rails.env.production?
        raise EnvironmentError.new("Cannot use InMemorySessionStore in a Production environment. \
          Please initialize DuodealerApp with a model that can store and retrieve sessions")
      end
      @@repo ||= {}
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
duodealer_app-1.0.4 lib/duodealer_app/session/in_memory_session_store.rb
duodealer_app-1.0.3 lib/duodealer_app/session/in_memory_session_store.rb
duodealer_app-1.0.2 lib/duodealer_app/session/in_memory_session_store.rb
duodealer_app-1.0.1 lib/duodealer_app/session/in_memory_session_store.rb
duodealer_app-1.0.0 lib/duodealer_app/session/in_memory_session_store.rb