Skip to content

Commit a35d481

Browse files
authored
MONGOID-5760 Update feature flags defaults and remove deprecations (#5811)
* configure defaults for <= 8.1 * deprecate "running_with_passenger?" * remove code deprecated <= 8.1 * fix failing specs
1 parent aef7114 commit a35d481

File tree

18 files changed

+50
-833
lines changed

18 files changed

+50
-833
lines changed

lib/mongoid/config.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,14 @@ def time_zone
376376
# config.running_with_passenger?
377377
#
378378
# @return [ true | false ] If the app is deployed on Passenger.
379+
#
380+
# @deprecated
379381
def running_with_passenger?
380382
@running_with_passenger ||= defined?(PhusionPassenger)
381383
end
382384

385+
Mongoid.deprecate(self, :running_with_passenger?)
386+
383387
private
384388

385389
def set_log_levels

lib/mongoid/config/defaults.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def load_defaults(version)
2525
when "8.1"
2626
self.immutable_ids = false
2727
self.legacy_persistence_context_behavior = true
28+
self.around_callbacks_for_embeds = true
29+
self.prevent_multiple_calls_of_embedded_callbacks = false
2830

2931
load_defaults "9.0"
3032
when "9.0"

lib/mongoid/contextual/geo_near.rb

Lines changed: 0 additions & 239 deletions
This file was deleted.

lib/mongoid/contextual/mongo.rb

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
require "mongoid/contextual/atomic"
77
require "mongoid/contextual/aggregable/mongo"
88
require "mongoid/contextual/command"
9-
require "mongoid/contextual/geo_near"
109
require "mongoid/contextual/map_reduce"
1110
require "mongoid/association/eager_loadable"
1211

@@ -24,8 +23,6 @@ class Mongo
2423
include Association::EagerLoadable
2524
include Queryable
2625

27-
Mongoid.deprecate(self, :geo_near)
28-
2926
# Options constant.
3027
OPTIONS = [ :hint,
3128
:limit,
@@ -263,29 +260,6 @@ def find_first
263260
end
264261
end
265262

266-
# Execute a $geoNear command against the database.
267-
#
268-
# @example Find documents close to 10, 10.
269-
# context.geo_near([ 10, 10 ])
270-
#
271-
# @example Find with spherical distance.
272-
# context.geo_near([ 10, 10 ]).spherical
273-
#
274-
# @example Find with a max distance.
275-
# context.geo_near([ 10, 10 ]).max_distance(0.5)
276-
#
277-
# @example Provide a distance multiplier.
278-
# context.geo_near([ 10, 10 ]).distance_multiplier(1133)
279-
#
280-
# @param [ Array<Float> ] coordinates The coordinates.
281-
#
282-
# @return [ GeoNear ] The GeoNear command.
283-
#
284-
# @deprecated
285-
def geo_near(coordinates)
286-
GeoNear.new(collection, criteria, coordinates)
287-
end
288-
289263
# Create the new Mongo context. This delegates operations to the
290264
# underlying driver.
291265
#

lib/mongoid/extensions/date.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ def mongoize(object)
7171
if object.is_a?(String)
7272
# https://jira.mongodb.org/browse/MONGOID-4460
7373
time = ::Time.parse(object)
74-
else
74+
elsif object.respond_to?(:__mongoize_time__)
7575
time = object.__mongoize_time__
76+
else
77+
nil
7678
end
7779
rescue ArgumentError
7880
nil

lib/mongoid/extensions/object.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@ def __find_args__
3232
end
3333
Mongoid.deprecate(self, :__find_args__)
3434

35-
# Mongoize a plain object into a time.
36-
#
37-
# @note This method should not be used, because it does not
38-
# return correct results for non-Time objects. Override
39-
# __mongoize_time__ in classes that are time-like to return an
40-
# instance of Time or ActiveSupport::TimeWithZone.
41-
#
42-
# @example Mongoize the object.
43-
# object.__mongoize_time__
44-
#
45-
# @return [ Object ] self.
46-
# @deprecated
47-
def __mongoize_time__
48-
self
49-
end
50-
5135
# Try to form a setter from this object.
5236
#
5337
# @example Try to form a setter.

lib/mongoid/extensions/time.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def demongoize(object)
7171
def mongoize(object)
7272
return if object.blank?
7373
begin
74-
time = object.__mongoize_time__
74+
time = object.respond_to?(:__mongoize_time__) ? object.__mongoize_time__ : nil
7575
rescue ArgumentError
7676
return
7777
end

lib/mongoid/findable.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ module Findable
3838
:for_js,
3939
:fourth,
4040
:fourth!,
41-
:geo_near,
4241
:includes,
4342
:last!,
4443
:map_reduce,

lib/mongoid/scopable.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,15 @@ def check_scope_validity(value)
289289
# @return [ Method ] The defined method.
290290
def define_scope_method(name)
291291
singleton_class.class_eval do
292-
ruby2_keywords(
293-
define_method(name) do |*args, **kwargs|
294-
scoping = _declared_scopes[name]
295-
scope = instance_exec(*args, **kwargs, &scoping[:scope])
296-
extension = scoping[:extension]
297-
to_merge = scope || queryable
298-
criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)
299-
criteria.extend(extension)
300-
criteria
301-
end
302-
)
292+
define_method(name) do |*args, **kwargs|
293+
scoping = _declared_scopes[name]
294+
scope = instance_exec(*args, **kwargs, &scoping[:scope])
295+
extension = scoping[:extension]
296+
to_merge = scope || queryable
297+
criteria = to_merge.empty_and_chainable? ? to_merge : with_default_scope.merge(to_merge)
298+
criteria.extend(extension)
299+
criteria
300+
end
303301
end
304302
end
305303

0 commit comments

Comments
 (0)