Sha256: 3068d07aab4df3f33cfd2b7f8eaa100793e274cf517ffcb2706b072c1aefdcac

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

class ShopifySessionRepository
  class ConfigurationError < StandardError; end

  class << self
    def storage=(storage)
      @storage = storage

      unless storage.nil? || self.storage.respond_to?(:store) && self.storage.respond_to?(:retrieve)
        raise ArgumentError, "storage must respond to :store and :retrieve"
      end
    end

    def retrieve(id)
      storage.retrieve(id)
    end

    def store(session)
      storage.store(session)
    end

    def storage
      load_storage || raise(ConfigurationError.new("ShopifySessionRepository.storage is not configured!"))
    end

    private

    def load_storage
      return unless @storage
      @storage.respond_to?(:safe_constantize) ? @storage.safe_constantize : @storage
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_app-5.0.2 lib/shopify_app/shopify_session_repository.rb
shopify_app-5.0.1 lib/shopify_app/shopify_session_repository.rb