Sha256: 97c477098d452595d604583f0644c6485ad8354b58e9cee497857fea1dedf157

Contents?: true

Size: 552 Bytes

Versions: 5

Compression:

Stored size: 552 Bytes

Contents

require "forwardable"

module FakeSQS
  class MemoryDatabase
    extend Forwardable

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

    def initialize
      @in_transaction = false
    end

    def load
      @queues = {}
    end

    def transaction
      if @in_transaction
        raise "Already in transaction"
      else
        @in_transaction = true
        begin
          yield
        ensure
          @in_transaction = false
        end
      end
    end

    def reset
      @queues = {}
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fake_sqs-0.3.0 lib/fake_sqs/memory_database.rb
fake_sqs-0.2.0 lib/fake_sqs/memory_database.rb
fake_sqs-0.1.0 lib/fake_sqs/memory_database.rb
fake_sqs-0.0.11 lib/fake_sqs/memory_database.rb
fake_sqs-0.0.10 lib/fake_sqs/memory_database.rb