class Datadog::Contrib::ActiveRecord::Configuration::Resolver
Converts Symbols, Strings, and Hashes to a normalized connection settings Hash.
Public Class Methods
new(configurations = nil)
click to toggle source
# File lib/ddtrace/contrib/active_record/configuration/resolver.rb, line 10 def initialize(configurations = nil) @configurations = configurations end
Public Instance Methods
configurations()
click to toggle source
# File lib/ddtrace/contrib/active_record/configuration/resolver.rb, line 18 def configurations @configurations || ::ActiveRecord::Base.configurations end
connection_resolver()
click to toggle source
# File lib/ddtrace/contrib/active_record/configuration/resolver.rb, line 22 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
normalize(hash)
click to toggle source
# File lib/ddtrace/contrib/active_record/configuration/resolver.rb, line 32 def normalize(hash) { adapter: hash[:adapter], host: hash[:host], port: hash[:port], database: hash[:database], username: hash[:username] } end
resolve(key)
click to toggle source
# File lib/ddtrace/contrib/active_record/configuration/resolver.rb, line 14 def resolve(key) normalize(connection_resolver.resolve(key).symbolize_keys) end