diff --git a/lib/mongoid/clients/factory.rb b/lib/mongoid/clients/factory.rb index 564e16eb40..acbc9c8a13 100644 --- a/lib/mongoid/clients/factory.rb +++ b/lib/mongoid/clients/factory.rb @@ -111,10 +111,6 @@ def build_auto_encryption_options(opts, database) version: VERSION }.freeze - def driver_version - Mongo::VERSION.split('.')[0...2].map(&:to_i) - end - # Prepare options for Mongo::Client based on Mongoid client configuration. # # @param [ Hash ] opts Parameters from options section of Mongoid client configuration. @@ -125,16 +121,14 @@ def options(opts) options = opts.dup options[:platform] = PLATFORM_DETAILS options[:app_name] = Mongoid::Config.app_name if Mongoid::Config.app_name - if (driver_version <=> [ 2, 13 ]) >= 0 - wrap_lib = if options[:wrapping_libraries] - [ MONGOID_WRAPPING_LIBRARY ] + options[:wrapping_libraries] - else - [ MONGOID_WRAPPING_LIBRARY ] - end.tap do |wrap| - wrap << { name: 'Rails', version: ::Rails.version } if defined?(::Rails) && ::Rails.respond_to?(:version) - end - options[:wrapping_libraries] = wrap_lib + wrap_lib = if options[:wrapping_libraries] + [ MONGOID_WRAPPING_LIBRARY ] + options[:wrapping_libraries] + else + [ MONGOID_WRAPPING_LIBRARY ] + end.tap do |wrap| + wrap << { name: 'Rails', version: ::Rails.version } if defined?(::Rails) && ::Rails.respond_to?(:version) end + options[:wrapping_libraries] = wrap_lib options.reject { |k, _v| k == :hosts }.to_hash.symbolize_keys! end end diff --git a/lib/mongoid/config.rb b/lib/mongoid/config.rb index 4df6129d90..c1b15ea240 100644 --- a/lib/mongoid/config.rb +++ b/lib/mongoid/config.rb @@ -548,6 +548,10 @@ def global_client end end + # Wraps configuration options that have been deprecated so that assigning + # them emits a deprecation warning. OPTIONS is intentionally empty when no + # options are currently deprecated; it is populated as options are retired, + # at which point this module rewrites their setters to warn. module DeprecatedOptions OPTIONS = %i[]