Sha256: be983849c52e2d60f90d8831d8da7b00494deeb8c70f8cd852f84d178d6ee408

Contents?: true

Size: 715 Bytes

Versions: 6

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Enrichers
    class Base
      include Mixins::Configurable

      class << self
        include Dry::Monads[:result, :try]

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

        def query_result(value)
          Try[StandardError] { query(value) }.to_result
        end

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

      # @return [Boolean]
      def valid?
        raise NotImplementedError, "You must implement #{self.class}##{__method__}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mihari-5.4.9 lib/mihari/enrichers/base.rb
mihari-5.4.8 lib/mihari/enrichers/base.rb
mihari-5.4.7 lib/mihari/enrichers/base.rb
mihari-5.4.6 lib/mihari/enrichers/base.rb
mihari-5.4.5 lib/mihari/enrichers/base.rb
mihari-5.4.4 lib/mihari/enrichers/base.rb