Sha256: caed5b80f9933e6256b923ebe9925326c7fbf12dd16210f7cdd5d80d659ef08b

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Enrichers
    class Base < Mihari::Base
      include Mixins::Configurable
      include Mixins::Retriable

      include Dry::Monads[:result, :try]

      def initialize(options: nil)
        super(options: options)
      end

      def query_result(value)
        Try[StandardError] do
          retry_on_error(
            times: retry_times,
            interval: retry_interval,
            exponential_backoff: retry_exponential_backoff
          ) { query value }
        end.to_result
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mihari-5.6.1 lib/mihari/enrichers/base.rb
mihari-5.6.0 lib/mihari/enrichers/base.rb