Sha256: 7618b78027e6b7047e0652a32d8f47667adf94db3244c3afbf662adc338e7400

Contents?: true

Size: 509 Bytes

Versions: 3

Compression:

Stored size: 509 Bytes

Contents

module Basket
  class BackendAdapter
    class HashBackend < Basket::BackendAdapter
      def initialize
        @data = {}
      end

      attr_reader :data

      def push(queue, data)
        @data[queue] = [] if @data[queue].nil?
        @data[queue] <<= data
      end

      def length(queue)
        return 0 if @data[queue].nil?

        @data[queue].length
      end

      def read(queue)
        @data[queue]
      end

      def clear(queue)
        @data[queue] = []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basket-0.0.5 lib/basket/backend_adapter/hash_backend.rb
basket-0.0.4 lib/basket/backend_adapter/hash_backend.rb
basket-0.0.3 lib/basket/backend_adapter/hash_backend.rb