Class: Datadog::Tracing::Contrib::Configuration::Resolvers::PatternResolver

Inherits:
Datadog::Tracing::Contrib::Configuration::Resolver show all
Defined in:
lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb

Overview

Matches Strings and Regexps against ‘object.to_s` objects and Procs against plain objects.

Instance Attribute Summary

Attributes inherited from Datadog::Tracing::Contrib::Configuration::Resolver

#configurations

Instance Method Summary collapse

Methods inherited from Datadog::Tracing::Contrib::Configuration::Resolver

#add, #get, #initialize

Constructor Details

This class inherits a constructor from Datadog::Tracing::Contrib::Configuration::Resolver

Instance Method Details

#resolve(value) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb', line 14

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