Class: GovukMessageQueueConsumer::MessageConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_message_queue_consumer/message_consumer.rb

Instance Method Summary collapse

Constructor Details

#initialize(processors:) ⇒ MessageConsumer

Returns a new instance of MessageConsumer.



3
4
5
# File 'lib/govuk_message_queue_consumer/message_consumer.rb', line 3

def initialize(processors:)
  @processors = processors
end

Instance Method Details

#process(records) ⇒ Object



7
8
9
10
11
# File 'lib/govuk_message_queue_consumer/message_consumer.rb', line 7

def process(records)
  @processors.inject(Array(records)) do |remaining_records, processor|
    remaining_records.select { |record| processor.process(record) }
  end
end