Sha256: 7d0abb98eebabba93d86702163cd694bd1ebf69608880e30c597346569284d7e

Contents?: true

Size: 511 Bytes

Versions: 1

Compression:

Stored size: 511 Bytes

Contents

module Basket
  class BackendAdapter
    class MemoryBackend < 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

1 entries across 1 versions & 1 rubygems

Version Path
basket-0.0.6 lib/basket/backend_adapter/memory_backend.rb