Sha256: 0241448fab9a48e3694cbfaf78ceea78862d7c8bd78516092c47ed310281dc7d
Contents?: true
Size: 1.41 KB
Versions: 19
Compression:
Stored size: 1.41 KB
Contents
require 'ddtrace/contrib/configuration/resolver' require 'ddtrace/vendor/active_record/connection_specification' module Datadog module Contrib module ActiveRecord module Configuration # Converts Symbols, Strings, and Hashes to a normalized connection settings Hash. class Resolver < Contrib::Configuration::Resolver def initialize(configurations = nil) @configurations = configurations end def resolve(key) normalize(connection_resolver.resolve(key).symbolize_keys) end def configurations @configurations || ::ActiveRecord::Base.configurations end def connection_resolver @resolver ||= begin if defined?(::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver) ::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations) else ::Datadog::Vendor::ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver.new(configurations) end end end def normalize(hash) { adapter: hash[:adapter], host: hash[:host], port: hash[:port], database: hash[:database], username: hash[:username] } end end end end end end
Version data entries
19 entries across 19 versions & 2 rubygems