Module: Jets::Job::Helpers::S3Event
- Included in:
- Base
- Defined in:
- lib/jets/job/helpers/s3_event.rb
Instance Method Summary collapse
-
#s3_event ⇒ Object
Deprecated methods below.
- #s3_events ⇒ Object (also: #s3_event_payloads)
- #s3_events? ⇒ Boolean (also: #s3_event_payloads?)
- #s3_object ⇒ Object
- #s3_objects ⇒ Object
- #s3_objects? ⇒ Boolean
Instance Method Details
#s3_event ⇒ Object
Deprecated methods below
36 37 38 39 40 41 |
# File 'lib/jets/job/helpers/s3_event.rb', line 36 def s3_event puts "WARN: s3_event is deprecated".color(:yellow) puts "It can possibly drop events when they come in extremely fast." puts "Use s3_events instead" s3_events.first end |
#s3_events ⇒ Object Also known as: s3_event_payloads
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/jets/job/helpers/s3_event.rb', line 3 def s3_events = event["Records"].map do |record| record["Sns"]["Message"] # SNS message is JSON end # Decode the JSON messages = .map do || JSON.load() end # Extract the S3 event records .map do || ["Records"].map do |record| ActiveSupport::HashWithIndifferentAccess.new(record) end end.flatten end |
#s3_events? ⇒ Boolean Also known as: s3_event_payloads?
20 21 22 |
# File 'lib/jets/job/helpers/s3_event.rb', line 20 def s3_events? event["Records"]&.any? { |r| r.dig("Sns", "Message") } end |
#s3_object ⇒ Object
43 44 45 46 47 48 |
# File 'lib/jets/job/helpers/s3_event.rb', line 43 def s3_object puts "WARN: s3_object is deprecated".color(:yellow) puts "It can possibly drop events when they come in extremely fast." puts "Use s3_objects instead" s3_objects.first end |
#s3_objects ⇒ Object
25 26 27 28 29 |
# File 'lib/jets/job/helpers/s3_event.rb', line 25 def s3_objects s3_events.map do |record| record["s3"]["object"] end end |
#s3_objects? ⇒ Boolean
31 32 33 |
# File 'lib/jets/job/helpers/s3_event.rb', line 31 def s3_objects? s3_events.any? { |r| r.dig("s3", "object") } end |