Sha256: 2ab7c2e17780e9e98c8dbb1945d8d35b405580ddea1c6ebabc74e06eff5bfcec

Contents?: true

Size: 1.11 KB

Versions: 32

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_relative '../resolver'

module Datadog
  module Tracing
    module Contrib
      module Configuration
        # Resolves a value to a configuration key
        module Resolvers
          # Matches Strings and Regexps against `object.to_s` objects
          # and Procs against plain objects.
          class PatternResolver < Contrib::Configuration::Resolver
            def resolve(value)
              return if configurations.empty?

              # Try to find a matching pattern
              _, config = configurations.reverse_each.find do |matcher, _|
                matcher === if matcher.is_a?(Proc)
                              value
                            else
                              value.to_s
                            end
              end

              config
            end

            protected

            def parse_matcher(matcher)
              if matcher.is_a?(Regexp) || matcher.is_a?(Proc)
                matcher
              else
                matcher.to_s
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
datadog-2.7.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.6.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.5.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.4.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.3.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.2.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.23.3 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.23.2 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.1.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.0.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.23.1 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.22.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.21.1 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.21.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.20.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.19.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.18.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb
ddtrace-1.17.0 lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb