Sha256: 0cb9c5a136f1560a7bf502b0b4e46dcaad2f9d182f6123129532a5755f264ff2

Contents?: true

Size: 640 Bytes

Versions: 2

Compression:

Stored size: 640 Bytes

Contents

module Euston
  module Idempotence
    extend ActiveSupport::Concern

    module InstanceMethods
      def if_unhandled obj, headers
        return if obj._history.include? headers.id

        obj._history << headers.id

        unless headers.source_message.nil? || obj._history.include?(headers.source_message[:headers][:id])
          obj._history << headers.source_message[:headers][:id]
        end

        yield
      end

      def if_exists_and_unhandled document_type, id, headers
        document = document_type.find id

        if_unhandled document, headers do
          yield document
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
euston-1.2.0 lib/euston/idempotence.rb
euston-1.2.0-java lib/euston/idempotence.rb