Class: ShopifyApp::InMemorySessionStore

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

Defined Under Namespace

Classes: EnvironmentError

Class Method Summary collapse

Class Method Details

.clearObject


15
16
17
# File 'lib/shopify_app/session/in_memory_session_store.rb', line 15

def self.clear
  @@repo = nil
end

.repoObject


19
20
21
22
23
24
25
# File 'lib/shopify_app/session/in_memory_session_store.rb', line 19

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

.retrieve(id) ⇒ Object


5
6
7
# File 'lib/shopify_app/session/in_memory_session_store.rb', line 5

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

.store(session) ⇒ Object


9
10
11
12
13
# File 'lib/shopify_app/session/in_memory_session_store.rb', line 9

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