Sha256: edab74aa14704202b4b609397c985f404ce2ebab31ebede02b7ff223ec06af20
Contents?: true
Size: 1.46 KB
Versions: 48
Compression:
Stored size: 1.46 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 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 resolve(spec) return :default if spec == :default normalize(connection_resolver.resolve(spec).symbolize_keys) 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
48 entries across 48 versions & 2 rubygems