Class: DuodealerApp::InMemorySessionStore

Inherits:
Object
  • Object
show all
Defined in:
lib/duodealer_app/session/in_memory_session_store.rb

Defined Under Namespace

Classes: EnvironmentError

Class Method Summary collapse

Class Method Details

.clearObject



17
18
19
# File 'lib/duodealer_app/session/in_memory_session_store.rb', line 17

def self.clear
  @@repo = nil
end

.repoObject



21
22
23
24
25
26
27
# File 'lib/duodealer_app/session/in_memory_session_store.rb', line 21

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

.retrieve(id) ⇒ Object



7
8
9
# File 'lib/duodealer_app/session/in_memory_session_store.rb', line 7

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

.store(session, *args) ⇒ Object



11
12
13
14
15
# File 'lib/duodealer_app/session/in_memory_session_store.rb', line 11

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