Module: Jets::Event::Helpers::SnsEvent

Included in:
Base
Defined in:
lib/jets/event/helpers/sns_event.rb

Instance Method Summary collapse

Instance Method Details

#sns_eventsObject



3
4
5
6
7
8
9
10
# File 'lib/jets/event/helpers/sns_event.rb', line 3

def sns_events
  records = event["Records"]
  return [] unless records
  records.map do |record|
    message = record["Sns"]["Message"]
    ActiveSupport::HashWithIndifferentAccess.new(JSON.load(message))
  end
end

#sns_events?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/jets/event/helpers/sns_event.rb', line 12

def sns_events?
  event["Records"]&.any? { |r| r.dig("Sns", "Message") }
end