Sha256: cdfbd871b2d131498e0b39edceb9f67741b8e7d1ef66d8ec41ae80b195ea32d7

Contents?: true

Size: 857 Bytes

Versions: 14

Compression:

Stored size: 857 Bytes

Contents

module FakeSQS
  module Actions
    class DeleteMessageBatch

      def initialize(options = {})
        @server    = options.fetch(:server)
        @queues    = options.fetch(:queues)
        @responder = options.fetch(:responder)
      end

      def call(name, params)
        queue = @queues.get(name)
        receipts = params.select { |k,v| k =~ /DeleteMessageBatchRequestEntry\.\d+\.ReceiptHandle/ }

        deleted = []

        receipts.each do |key, value|
          id = key.split('.')[1]
          queue.delete_message(value)
          deleted << params.fetch("DeleteMessageBatchRequestEntry.#{id}.Id")
        end

        @responder.call :DeleteMessageBatch do |xml|
          deleted.each do |id|
            xml.DeleteMessageBatchResultEntry do
              xml.Id id
            end
          end
        end
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fake_sqs-0.4.1 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.4.0 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.3.1 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.3.0 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.2.0 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.1.0 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.11 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.10 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.9 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.8 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.7 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.6 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.5 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.0.4 lib/fake_sqs/actions/delete_message_batch.rb