Sha256: 0ff3e5a1a3b904834e4374e5e6594f21382394d1541464fd0df8bfc201025f99

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 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(queue_name, params)
        queue = @queues.get(queue_name)
        receipts = params.select { |k,v| k =~ /DeleteMessageBatchRequestEntry\.\d+\.ReceiptHandle/ }

        deleted = receipts.each do |key, value|
          id = key.split('.')[1]
          queue.delete_message(value) # Broken, can only delete in-flight messages
          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

2 entries across 2 versions & 1 rubygems

Version Path
fake_sqs-0.4.3 lib/fake_sqs/actions/delete_message_batch.rb
fake_sqs-0.4.2 lib/fake_sqs/actions/delete_message_batch.rb