Sha256: 2c1f6e96d811e33b8cb9ab4f6429dd00bc04a6522bb74de66f1bdf9696a88dfb

Contents?: true

Size: 839 Bytes

Versions: 11

Compression:

Stored size: 839 Bytes

Contents

module ShopifyApp
  class SessionRepository
    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, *args)
        storage.store(session, *args)
      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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify_app-12.0.7 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.6 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.5 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.4 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.3 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.2 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.1 lib/shopify_app/session/session_repository.rb
shopify_app-12.0.0 lib/shopify_app/session/session_repository.rb
shopify_app-11.7.1 lib/shopify_app/session/session_repository.rb
shopify_app-11.7.0 lib/shopify_app/session/session_repository.rb
shopify_app-11.5.0 lib/shopify_app/session/session_repository.rb