Module: Mongoid::Config::Defaults

Included in:
Mongoid::Config
Defined in:
build/mongoid-master/lib/mongoid/config/defaults.rb

Overview

Encapsulates logic for loading defaults.

Instance Method Summary collapse

Instance Method Details

#load_defaults(version) ⇒ Object

Load the defaults for the feature flags in the given Mongoid version. Note that this method will load the new functionality introduced in the given Mongoid version.

raises [ ArgumentError ] if an invalid version is given.

Parameters:

  • The (String | Float)

    version number as X.y.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'build/mongoid-master/lib/mongoid/config/defaults.rb', line 16

def load_defaults(version)
  # Note that for 7.x, since all of the feature flag defaults have been
  # flipped to the new functionality, all of the settings for those
  # versions are to give old functionality. Because of this, it is
  # possible to recurse to later version to get all of the options to
  # turn off. Note that this won't be true when adding feature flags to
  # 9.x, since the default will be the old functionality until the next
  # major version is released. More likely, the recursion will have to go
  # in the other direction (towards earlier versions).

  case version.to_s
  when "7.3"
    # flags introduced in 7.4 - old functionality
    self.broken_aggregables = true
    self.broken_alias_handling = true
    self.broken_and = true
    self.broken_scoping = true
    self.broken_updates = true
    self.compare_time_by_ms = false
    self.legacy_pluck_distinct = true
    self.legacy_triple_equals = true
    self.object_id_as_json_oid = true

    load_defaults "7.4"
  when "7.4"
    # flags introduced in 7.5 - old functionality
    self.legacy_attributes = true
    self.overwrite_chained_operators = true

    load_defaults "7.5"
  when "7.5"
    # flags introduced in 8.0 - old functionality
    self.map_big_decimal_to_decimal128 = false
  when "8.0"
    # All flag defaults currently reflect 8.0 behavior.
    self.legacy_readonly = true
  when "8.1"
    # All flag defaults currently reflect 8.1 behavior.
  when "9.0"
    # All flag defaults currently reflect 9.0 behavior.
  else
    raise ArgumentError, "Unknown version: #{version}"
  end
end