Sha256: 21a9400bfc4e29078718bdd64e16888c5099262ccf54980a508bd93430798c17

Contents?: true

Size: 488 Bytes

Versions: 6

Compression:

Stored size: 488 Bytes

Contents

module DiscoApp
  class SessionStorage

    def self.store(session, *args)
      shop = Shop.find_or_initialize_by(shopify_domain: session.url)
      shop.shopify_token = session.token
      shop.save!
      shop.id
    end

    def self.retrieve(id)
      return unless id

      shop = Shop.find(id)
      ShopifyAPI::Session.new(domain: shop.shopify_domain, token: shop.shopify_token, api_version: shop.api_version)
    rescue ActiveRecord::RecordNotFound
      nil
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
disco_app-0.18.0 app/models/disco_app/session_storage.rb
disco_app-0.18.2 app/models/disco_app/session_storage.rb
disco_app-0.18.3 app/models/disco_app/session_storage.rb
disco_app-0.18.6 app/models/disco_app/session_storage.rb
disco_app-0.18.4 app/models/disco_app/session_storage.rb
disco_app-0.18.1 app/models/disco_app/session_storage.rb