Class: Dionysus::Producer::Outbox::DuplicatesFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/outbox/duplicates_filter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records_to_publish) ⇒ DuplicatesFilter

Returns a new instance of DuplicatesFilter.



11
12
13
# File 'lib/dionysus/producer/outbox/duplicates_filter.rb', line 11

def initialize(records_to_publish)
  @records_to_publish = records_to_publish
end

Class Method Details

.call(records_to_publish) ⇒ Object



4
5
6
# File 'lib/dionysus/producer/outbox/duplicates_filter.rb', line 4

def self.call(records_to_publish)
  new(records_to_publish).call
end

Instance Method Details

#callObject



15
16
17
18
19
# File 'lib/dionysus/producer/outbox/duplicates_filter.rb', line 15

def call
  records_to_publish
    .slice_when { |record_1, record_2| generate_uniqueness_key(record_1) != generate_uniqueness_key(record_2) }
    .flat_map(&:last)
end