Sha256: b60aacb60b10f83ed4418e6d6642fa97d2374bde45eb5a1507c89dc9e8940b0a

Contents?: true

Size: 417 Bytes

Versions: 5

Compression:

Stored size: 417 Bytes

Contents

require "forwardable"
require "thread"

module FakeSQS
  class MemoryDatabase
    extend Forwardable

    def_delegators :@queues,
      :[], :[]=, :delete, :each, :select, :values

    def initialize
      @semaphore = Mutex.new
    end

    def load
      @queues = {}
    end

    def transaction
      @semaphore.synchronize do
        yield
      end
    end

    def reset
      @queues = {}
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fake_sqs-0.4.3 lib/fake_sqs/databases/memory.rb
fake_sqs-0.4.2 lib/fake_sqs/databases/memory.rb
fake_sqs-0.4.1 lib/fake_sqs/databases/memory.rb
fake_sqs-0.4.0 lib/fake_sqs/databases/memory.rb
fake_sqs-0.3.1 lib/fake_sqs/memory_database.rb