Sha256: f6fb28d1fd484e1efeee01d6ee04ca8cbb903d81583f5bcb5271a9a410ce9c69

Contents?: true

Size: 882 Bytes

Versions: 4

Compression:

Stored size: 882 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Enrichers
    #
    # Base class for enrichers
    #
    class Base < Actor
      def initialize(options: nil)
        super(options: options)
      end

      #
      # @param [String] value
      #
      def call(value)
        raise NotImplementedError, "You must implement #{self.class}##{__method__}"
      end

      #
      # @return [Dry::Monads::Result::Success<Object>, Dry::Monads::Result::Failure]
      #
      def result(value)
        Try[StandardError] do
          retry_on_error(
            times: retry_times,
            interval: retry_interval,
            exponential_backoff: retry_exponential_backoff
          ) { call value }
        end.to_result
      end

      class << self
        def inherited(child)
          super
          Mihari.enrichers << child
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mihari-6.0.0 lib/mihari/enrichers/base.rb
mihari-5.7.2 lib/mihari/enrichers/base.rb
mihari-5.7.1 lib/mihari/enrichers/base.rb
mihari-5.7.0 lib/mihari/enrichers/base.rb