Sha256: 6e2f3a2f681f6774cbf890046b24e605361c8ecb7bddae939bb89a46d729a992

Contents?: true

Size: 435 Bytes

Versions: 1

Compression:

Stored size: 435 Bytes

Contents

module DiscoApp
  class SessionStorage

    def self.store(session)
      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(shop.shopify_domain, shop.shopify_token)
    rescue ActiveRecord::RecordNotFound
      nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
disco_app-0.17.0 app/models/disco_app/session_storage.rb