Class: ShopifyApp::InMemorySessionStore

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

Overview

rubocop:disable Style/ClassVars Class var repo is needed here in order to share data between the 2 child classes.

Defined Under Namespace

Classes: EnvironmentError

Class Method Summary collapse

Class Method Details

.clearObject



18
19
20
# File 'lib/ruby_shopify_app/session/in_memory_session_store.rb', line 18

def self.clear
  @@repo = nil
end

.repoObject



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

def self.repo
  if Rails.env.production?
    raise EnvironmentError, "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



8
9
10
# File 'lib/ruby_shopify_app/session/in_memory_session_store.rb', line 8

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

.store(session, *_args) ⇒ Object



12
13
14
15
16
# File 'lib/ruby_shopify_app/session/in_memory_session_store.rb', line 12

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