Sha256: 31dc374706992e6478e886a838bb8ecf9f8260af8b8b27b0a6a32b1fad805cec

Contents?: true

Size: 434 Bytes

Versions: 4

Compression:

Stored size: 434 Bytes

Contents

module Jets::Event::Helpers
  module SqsEvent
    extend Memoist

    def sqs_records
      event[:Records].map { |record| record }
    end
    memoize :sqs_records

    def sqs_events
      records = sqs_records
      return [] unless records
      records.map do |record|
        JSON.parse(record[:body])
      end
    end
    memoize :sqs_events

    def sqs_events?
      sqs_records&.any? { |r| r.dig(:body) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/event/helpers/sqs_event.rb
jets-6.0.4 lib/jets/event/helpers/sqs_event.rb
jets-6.0.3 lib/jets/event/helpers/sqs_event.rb
jets-6.0.2 lib/jets/event/helpers/sqs_event.rb