Sha256: 78bbc9c8e7911ccfb4be53545222fc0087fbb1fbfd0d0ac1b7ba4eca4386af50

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module FakeSQS
  module Actions
    class ChangeMessageVisibilityBatch

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

      def call(queue_name, params)
        queue = @queues.get(queue_name)

        keys = params.keys.map do |key|
          case key
            when /^ChangeMessageVisibilityBatchRequestEntry\.(\w+)\.Id$/
              $1
          end
        end.compact

        ids = keys.map do |key|
          receipt = params.fetch("ChangeMessageVisibilityBatchRequestEntry.#{key}.ReceiptHandle")
          timeout = params.fetch("ChangeMessageVisibilityBatchRequestEntry.#{key}.VisibilityTimeout").to_i
          queue.change_message_visibility(receipt, timeout)
          params.fetch("ChangeMessageVisibilityBatchRequestEntry.#{key}.Id")
        end

        @responder.call :ChangeMessageVisibilityBatch do |xml|
          ids.each do |id|
            xml.ChangeMessageVisibilityBatchResultEntry 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/change_message_visibility_batch.rb
fake_sqs-0.4.2 lib/fake_sqs/actions/change_message_visibility_batch.rb