Skip to content

Commit e997b0e

Browse files
committed
MONGOID-5931 Remove obsolete driver-version guard and document DeprecatedOptions
Audited the codebase for dead and unreachable code using RuboCop lint cops, debride, and a grep/AST caller cross-reference. The codebase is largely free of dead code; the one genuine site was an obsolete guard. - clients/factory.rb: drop the `driver_version <=> [2, 13]` guard, which is always true now that the gemspec requires mongo >= 2.18.0, and remove the now-unused driver_version helper. - config.rb: document that DeprecatedOptions::OPTIONS is intentionally empty when no options are deprecated.
1 parent cc06903 commit e997b0e

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

lib/mongoid/clients/factory.rb

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ def build_auto_encryption_options(opts, database)
111111
version: VERSION
112112
}.freeze
113113

114-
def driver_version
115-
Mongo::VERSION.split('.')[0...2].map(&:to_i)
116-
end
117-
118114
# Prepare options for Mongo::Client based on Mongoid client configuration.
119115
#
120116
# @param [ Hash ] opts Parameters from options section of Mongoid client configuration.
@@ -125,16 +121,14 @@ def options(opts)
125121
options = opts.dup
126122
options[:platform] = PLATFORM_DETAILS
127123
options[:app_name] = Mongoid::Config.app_name if Mongoid::Config.app_name
128-
if (driver_version <=> [ 2, 13 ]) >= 0
129-
wrap_lib = if options[:wrapping_libraries]
130-
[ MONGOID_WRAPPING_LIBRARY ] + options[:wrapping_libraries]
131-
else
132-
[ MONGOID_WRAPPING_LIBRARY ]
133-
end.tap do |wrap|
134-
wrap << { name: 'Rails', version: ::Rails.version } if defined?(::Rails) && ::Rails.respond_to?(:version)
135-
end
136-
options[:wrapping_libraries] = wrap_lib
124+
wrap_lib = if options[:wrapping_libraries]
125+
[ MONGOID_WRAPPING_LIBRARY ] + options[:wrapping_libraries]
126+
else
127+
[ MONGOID_WRAPPING_LIBRARY ]
128+
end.tap do |wrap|
129+
wrap << { name: 'Rails', version: ::Rails.version } if defined?(::Rails) && ::Rails.respond_to?(:version)
137130
end
131+
options[:wrapping_libraries] = wrap_lib
138132
options.reject { |k, _v| k == :hosts }.to_hash.symbolize_keys!
139133
end
140134
end

lib/mongoid/config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ def global_client
548548
end
549549
end
550550

551+
# Wraps configuration options that have been deprecated so that assigning
552+
# them emits a deprecation warning. OPTIONS is intentionally empty when no
553+
# options are currently deprecated; it is populated as options are retired,
554+
# at which point this module rewrites their setters to warn.
551555
module DeprecatedOptions
552556
OPTIONS = %i[]
553557

0 commit comments

Comments
 (0)