mongoid 8.0.1 → 8.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/config/locales/en.yml +1 -0
  4. data/lib/mongoid/association/accessors.rb +6 -6
  5. data/lib/mongoid/association/bindable.rb +2 -2
  6. data/lib/mongoid/association/constrainable.rb +0 -1
  7. data/lib/mongoid/association/embedded/batchable.rb +5 -5
  8. data/lib/mongoid/association/embedded/cyclic.rb +1 -1
  9. data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -2
  10. data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
  11. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +10 -10
  12. data/lib/mongoid/association/embedded/embeds_many.rb +2 -2
  13. data/lib/mongoid/association/embedded/embeds_one/proxy.rb +2 -2
  14. data/lib/mongoid/association/embedded/embeds_one.rb +3 -3
  15. data/lib/mongoid/association/many.rb +6 -7
  16. data/lib/mongoid/association/nested/many.rb +3 -3
  17. data/lib/mongoid/association/nested/nested_buildable.rb +4 -4
  18. data/lib/mongoid/association/nested/one.rb +5 -5
  19. data/lib/mongoid/association/one.rb +2 -2
  20. data/lib/mongoid/association/options.rb +9 -9
  21. data/lib/mongoid/association/proxy.rb +2 -3
  22. data/lib/mongoid/association/referenced/auto_save.rb +1 -1
  23. data/lib/mongoid/association/referenced/belongs_to/proxy.rb +5 -6
  24. data/lib/mongoid/association/referenced/belongs_to.rb +1 -1
  25. data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
  26. data/lib/mongoid/association/referenced/eager.rb +2 -2
  27. data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +2 -2
  28. data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +2 -2
  29. data/lib/mongoid/association/referenced/has_many/enumerable.rb +10 -10
  30. data/lib/mongoid/association/referenced/has_many/proxy.rb +12 -9
  31. data/lib/mongoid/association/referenced/has_many.rb +3 -3
  32. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +5 -5
  33. data/lib/mongoid/association/referenced/has_one/proxy.rb +1 -1
  34. data/lib/mongoid/association/referenced/has_one.rb +3 -3
  35. data/lib/mongoid/association/referenced/syncable.rb +2 -2
  36. data/lib/mongoid/association/reflections.rb +2 -2
  37. data/lib/mongoid/association/relatable.rb +6 -6
  38. data/lib/mongoid/association.rb +5 -5
  39. data/lib/mongoid/atomic/modifiers.rb +2 -2
  40. data/lib/mongoid/attributes/dynamic.rb +3 -3
  41. data/lib/mongoid/attributes/nested.rb +5 -5
  42. data/lib/mongoid/attributes/processing.rb +1 -1
  43. data/lib/mongoid/attributes/projector.rb +1 -1
  44. data/lib/mongoid/attributes/readonly.rb +2 -2
  45. data/lib/mongoid/attributes.rb +13 -13
  46. data/lib/mongoid/changeable.rb +5 -5
  47. data/lib/mongoid/clients/options.rb +1 -1
  48. data/lib/mongoid/clients/validators/storage.rb +3 -3
  49. data/lib/mongoid/config/validators/client.rb +6 -6
  50. data/lib/mongoid/config.rb +7 -7
  51. data/lib/mongoid/contextual/aggregable/memory.rb +1 -1
  52. data/lib/mongoid/contextual/aggregable/mongo.rb +4 -4
  53. data/lib/mongoid/contextual/aggregable/none.rb +1 -1
  54. data/lib/mongoid/contextual/atomic.rb +1 -1
  55. data/lib/mongoid/contextual/geo_near.rb +7 -7
  56. data/lib/mongoid/contextual/memory.rb +5 -5
  57. data/lib/mongoid/contextual/mongo.rb +14 -14
  58. data/lib/mongoid/contextual/none.rb +2 -2
  59. data/lib/mongoid/contextual/queryable.rb +1 -1
  60. data/lib/mongoid/contextual.rb +2 -2
  61. data/lib/mongoid/criteria/findable.rb +7 -4
  62. data/lib/mongoid/criteria/includable.rb +1 -1
  63. data/lib/mongoid/criteria/permission.rb +1 -1
  64. data/lib/mongoid/criteria/queryable/aggregable.rb +2 -2
  65. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  66. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +2 -2
  67. data/lib/mongoid/criteria/queryable/extensions/set.rb +1 -1
  68. data/lib/mongoid/criteria/queryable/extensions/string.rb +3 -3
  69. data/lib/mongoid/criteria/queryable/extensions/symbol.rb +1 -1
  70. data/lib/mongoid/criteria/queryable/key.rb +3 -3
  71. data/lib/mongoid/criteria/queryable/optional.rb +2 -2
  72. data/lib/mongoid/criteria/queryable/options.rb +1 -1
  73. data/lib/mongoid/criteria/queryable/pipeline.rb +1 -1
  74. data/lib/mongoid/criteria/queryable/selectable.rb +3 -3
  75. data/lib/mongoid/criteria/queryable/selector.rb +3 -3
  76. data/lib/mongoid/criteria/queryable/smash.rb +1 -1
  77. data/lib/mongoid/criteria/queryable.rb +1 -1
  78. data/lib/mongoid/criteria/scopable.rb +2 -2
  79. data/lib/mongoid/criteria.rb +14 -9
  80. data/lib/mongoid/deprecable.rb +1 -1
  81. data/lib/mongoid/document.rb +2 -2
  82. data/lib/mongoid/equality.rb +12 -12
  83. data/lib/mongoid/errors/document_not_found.rb +5 -5
  84. data/lib/mongoid/errors/invalid_config_option.rb +1 -1
  85. data/lib/mongoid/errors/invalid_dependent_strategy.rb +1 -1
  86. data/lib/mongoid/errors/invalid_field.rb +1 -1
  87. data/lib/mongoid/errors/invalid_relation.rb +1 -1
  88. data/lib/mongoid/errors/invalid_relation_option.rb +1 -1
  89. data/lib/mongoid/errors/invalid_session_use.rb +1 -1
  90. data/lib/mongoid/errors/invalid_storage_options.rb +1 -1
  91. data/lib/mongoid/errors/mongoid_error.rb +3 -3
  92. data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +1 -1
  93. data/lib/mongoid/errors/no_client_database.rb +1 -1
  94. data/lib/mongoid/errors/no_client_hosts.rb +1 -1
  95. data/lib/mongoid/errors/readonly_attribute.rb +1 -1
  96. data/lib/mongoid/errors/unknown_attribute.rb +1 -1
  97. data/lib/mongoid/extensions/array.rb +1 -1
  98. data/lib/mongoid/extensions/false_class.rb +1 -1
  99. data/lib/mongoid/extensions/hash.rb +1 -1
  100. data/lib/mongoid/extensions/module.rb +1 -1
  101. data/lib/mongoid/extensions/object.rb +6 -6
  102. data/lib/mongoid/extensions/string.rb +9 -9
  103. data/lib/mongoid/extensions/symbol.rb +1 -1
  104. data/lib/mongoid/extensions/true_class.rb +1 -1
  105. data/lib/mongoid/fields/foreign_key.rb +4 -4
  106. data/lib/mongoid/fields/localized.rb +2 -2
  107. data/lib/mongoid/fields/standard.rb +7 -7
  108. data/lib/mongoid/fields.rb +9 -9
  109. data/lib/mongoid/findable.rb +7 -6
  110. data/lib/mongoid/indexable/specification.rb +1 -1
  111. data/lib/mongoid/indexable/validators/options.rb +2 -1
  112. data/lib/mongoid/interceptable.rb +4 -4
  113. data/lib/mongoid/matchable.rb +1 -1
  114. data/lib/mongoid/matcher.rb +12 -7
  115. data/lib/mongoid/persistable/creatable.rb +4 -4
  116. data/lib/mongoid/persistable/deletable.rb +1 -1
  117. data/lib/mongoid/persistable/destroyable.rb +1 -1
  118. data/lib/mongoid/persistable/savable.rb +2 -2
  119. data/lib/mongoid/persistable/unsettable.rb +1 -1
  120. data/lib/mongoid/persistable/updatable.rb +7 -7
  121. data/lib/mongoid/persistable/upsertable.rb +1 -1
  122. data/lib/mongoid/persistable.rb +3 -3
  123. data/lib/mongoid/persistence_context.rb +3 -3
  124. data/lib/mongoid/query_cache.rb +2 -2
  125. data/lib/mongoid/scopable.rb +17 -15
  126. data/lib/mongoid/serializable.rb +10 -6
  127. data/lib/mongoid/stateful.rb +10 -10
  128. data/lib/mongoid/tasks/database.rb +0 -2
  129. data/lib/mongoid/threaded/lifecycle.rb +5 -5
  130. data/lib/mongoid/threaded.rb +9 -9
  131. data/lib/mongoid/timestamps/updated.rb +1 -1
  132. data/lib/mongoid/traversable.rb +3 -3
  133. data/lib/mongoid/validatable/localizable.rb +1 -1
  134. data/lib/mongoid/validatable/macros.rb +0 -2
  135. data/lib/mongoid/validatable/presence.rb +2 -2
  136. data/lib/mongoid/validatable/uniqueness.rb +7 -7
  137. data/lib/mongoid/validatable.rb +6 -6
  138. data/lib/mongoid/version.rb +1 -1
  139. data/spec/mongoid/equality_spec.rb +12 -12
  140. data/spec/mongoid/indexable_spec.rb +23 -1
  141. data/spec/mongoid/scopable_spec.rb +34 -16
  142. data.tar.gz.sig +0 -0
  143. metadata +2 -2
  144. metadata.gz.sig +0 -0
@@ -118,7 +118,7 @@ module Mongoid
118
118
  #
119
119
  # @param [ Object ] other The object to be compared with this one.
120
120
  #
121
- # @return [ true, false ] Whether the two persistence contexts are equal.
121
+ # @return [ true | false ] Whether the two persistence contexts are equal.
122
122
  def ==(other)
123
123
  return false unless other.is_a?(PersistenceContext)
124
124
  options == other.options
@@ -184,7 +184,7 @@ module Mongoid
184
184
  # PersistenceContext.set(model)
185
185
  #
186
186
  # @param [ Object ] object The class or model instance.
187
- # @param [ Hash, Mongoid::PersistenceContext ] options_or_context The persistence
187
+ # @param [ Hash | Mongoid::PersistenceContext ] options_or_context The persistence
188
188
  # options or a persistence context object.
189
189
  #
190
190
  # @return [ Mongoid::PersistenceContext ] The persistence context for the object.
@@ -221,7 +221,7 @@ module Mongoid
221
221
  # @example Clear the persistence context for a class or model instance.
222
222
  # PersistenceContext.clear(model)
223
223
  #
224
- # @param [ Class, Object ] object The class or model instance.
224
+ # @param [ Class | Object ] object The class or model instance.
225
225
  # @param [ Mongo::Cluster ] cluster The original cluster before this context was used.
226
226
  # @param [ Mongoid::PersistenceContext ] original_context The original persistence
227
227
  # context that was set before this context was used.
@@ -22,7 +22,7 @@ module Mongoid
22
22
  # @example Set if the cache is enabled.
23
23
  # QueryCache.enabled = true
24
24
  #
25
- # @param [ true, false ] value The enabled value.
25
+ # @param [ true | false ] value The enabled value.
26
26
  def enabled=(value)
27
27
  Mongo::QueryCache.enabled = value
28
28
  end
@@ -32,7 +32,7 @@ module Mongoid
32
32
  # @example Is the query cache enabled?
33
33
  # QueryCache.enabled?
34
34
  #
35
- # @return [ true, false ] If the cache is enabled.
35
+ # @return [ true | false ] If the cache is enabled.
36
36
  def enabled?
37
37
  Mongo::QueryCache.enabled?
38
38
  end
@@ -23,7 +23,7 @@ module Mongoid
23
23
  # @example Apply the default scoping.
24
24
  # document.apply_default_scoping
25
25
  #
26
- # @return [ true, false ] If default scoping was applied.
26
+ # @return [ true | false ] If default scoping was applied.
27
27
  def apply_default_scoping
28
28
  if default_scoping
29
29
  default_scoping.call.selector.each do |field, value|
@@ -74,7 +74,7 @@ module Mongoid
74
74
  # default_scope ->{ where(active: true) }
75
75
  # end
76
76
  #
77
- # @param [ Proc, Criteria ] value The default scope.
77
+ # @param [ Proc | Criteria ] value The default scope.
78
78
  #
79
79
  # @raise [ Errors::InvalidScope ] If the scope is not a proc or criteria.
80
80
  #
@@ -90,7 +90,7 @@ module Mongoid
90
90
  # @example Can the default scope be applied?
91
91
  # Band.default_scopable?
92
92
  #
93
- # @return [ true, false ] If the default scope can be applied.
93
+ # @return [ true | false ] If the default scope can be applied.
94
94
  def default_scopable?
95
95
  default_scoping? && !Threaded.without_default_scope?(self)
96
96
  end
@@ -170,7 +170,7 @@ module Mongoid
170
170
  #
171
171
  # @note This will force the default scope to be removed.
172
172
  #
173
- # @return [ Criteria, Object ] The unscoped criteria or result of the
173
+ # @return [ Criteria | Object ] The unscoped criteria or result of the
174
174
  # block.
175
175
  def unscoped
176
176
  if block_given?
@@ -240,7 +240,7 @@ module Mongoid
240
240
  # @example Warn or raise error if name exists.
241
241
  # Model.valid_scope_name?("test")
242
242
  #
243
- # @param [ String, Symbol ] name The name of the scope.
243
+ # @param [ String | Symbol ] name The name of the scope.
244
244
  #
245
245
  # @raise [ Errors::ScopeOverwrite ] If the name exists and configured to
246
246
  # raise the error.
@@ -289,15 +289,17 @@ module Mongoid
289
289
  # @return [ Method ] The defined method.
290
290
  def define_scope_method(name)
291
291
  singleton_class.class_eval do
292
- define_method(name) do |*args|
293
- scoping = _declared_scopes[name]
294
- scope = instance_exec(*args, &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
292
+ ruby2_keywords(
293
+ define_method(name) do |*args|
294
+ scoping = _declared_scopes[name]
295
+ scope = instance_exec(*args, &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
+ )
301
303
  end
302
304
  end
303
305
 
@@ -309,7 +311,7 @@ module Mongoid
309
311
  # @example Process the default scope.
310
312
  # Model.process_default_scope(value)
311
313
  #
312
- # @param [ Criteria, Proc ] value The default scope value.
314
+ # @param [ Criteria | Proc ] value The default scope value.
313
315
  def process_default_scope(value)
314
316
  if existing = default_scoping
315
317
  ->{ existing.call.merge(value.to_proc.call) }
@@ -33,10 +33,14 @@ module Mongoid
33
33
  #
34
34
  # @param [ Hash ] options The options to pass.
35
35
  #
36
- # @option options [ Symbol ] :include What associations to include.
37
- # @option options [ Symbol ] :only Limit the fields to only these.
38
- # @option options [ Symbol ] :except Dont include these fields.
39
- # @option options [ Symbol ] :methods What methods to include.
36
+ # @option options [ Symbol | String | Array<Symbol | String> ] :except
37
+ # Do not include these field(s).
38
+ # @option options [ Symbol | String | Array<Symbol | String> ] :include
39
+ # Which association(s) to include.
40
+ # @option options [ Symbol | String | Array<Symbol | String> ] :only
41
+ # Limit the field(s) to only these.
42
+ # @option options [ Symbol | String | Array<Symbol | String> ] :methods
43
+ # What methods to include.
40
44
  #
41
45
  # @return [ Hash ] The document, ready to be serialized.
42
46
  def serializable_hash(options = nil)
@@ -137,7 +141,7 @@ module Mongoid
137
141
  # @example Get the association names.
138
142
  # document.relation_names(:include => [ :addresses ])
139
143
  #
140
- # @param [ Hash, Symbol, Array<Symbol> ] inclusions The inclusions.
144
+ # @param [ Hash | Symbol | Array<Symbol> ] inclusions The inclusions.
141
145
  #
142
146
  # @return [ Array<Symbol> ] The names of the included associations.
143
147
  def relation_names(inclusions)
@@ -150,7 +154,7 @@ module Mongoid
150
154
  # @example Get the association options.
151
155
  # document.relation_names(:include => [ :addresses ])
152
156
  #
153
- # @param [ Hash, Symbol, Array<Symbol> ] inclusions The inclusions.
157
+ # @param [ Hash | Symbol | Array<Symbol> ] inclusions The inclusions.
154
158
  # @param [ Hash ] options The options.
155
159
  # @param [ Symbol ] name The name of the association.
156
160
  #
@@ -23,7 +23,7 @@ module Mongoid
23
23
  # @example Is the document new?
24
24
  # person.new_record?
25
25
  #
26
- # @return [ true, false ] True if new, false if not.
26
+ # @return [ true | false ] True if new, false if not.
27
27
  def new_record?
28
28
  @new_record ||= false
29
29
  end
@@ -32,7 +32,7 @@ module Mongoid
32
32
  # save, the object didn't exist in the database and new_record? would have
33
33
  # returned true.
34
34
  #
35
- # @return [ true, false ] True if was just created, false if not.
35
+ # @return [ true | false ] True if was just created, false if not.
36
36
  def previously_new_record?
37
37
  @previously_new_record ||= false
38
38
  end
@@ -43,7 +43,7 @@ module Mongoid
43
43
  # @example Is the document persisted?
44
44
  # person.persisted?
45
45
  #
46
- # @return [ true, false ] True if persisted, false if not.
46
+ # @return [ true | false ] True if persisted, false if not.
47
47
  def persisted?
48
48
  !new_record? && !destroyed?
49
49
  end
@@ -51,7 +51,7 @@ module Mongoid
51
51
  # Checks if the document was previously saved to the database
52
52
  # but now it has been deleted.
53
53
  #
54
- # @return [ true, false ] True if was persisted but now destroyed,
54
+ # @return [ true | false ] True if was persisted but now destroyed,
55
55
  # otherwise false.
56
56
  def previously_persisted?
57
57
  !new_record? && destroyed?
@@ -63,7 +63,7 @@ module Mongoid
63
63
  # @example Is the document flagged?
64
64
  # document.flagged_for_destroy?
65
65
  #
66
- # @return [ true, false ] If the document is flagged.
66
+ # @return [ true | false ] If the document is flagged.
67
67
  def flagged_for_destroy?
68
68
  @flagged_for_destroy ||= false
69
69
  end
@@ -77,7 +77,7 @@ module Mongoid
77
77
  # @example Is the document destroyed?
78
78
  # person.destroyed?
79
79
  #
80
- # @return [ true, false ] True if destroyed, false if not.
80
+ # @return [ true | false ] True if destroyed, false if not.
81
81
  def destroyed?
82
82
  @destroyed ||= false
83
83
  end
@@ -87,7 +87,7 @@ module Mongoid
87
87
  # @example Is this pushable?
88
88
  # person.pushable?
89
89
  #
90
- # @return [ true, false ] Is the document new and embedded?
90
+ # @return [ true | false ] Is the document new and embedded?
91
91
  def pushable?
92
92
  new_record? &&
93
93
  embedded_many? &&
@@ -100,7 +100,7 @@ module Mongoid
100
100
  # @example Is the document readonly?
101
101
  # document.readonly?
102
102
  #
103
- # @return [ true, false ] If the document is readonly.
103
+ # @return [ true | false ] If the document is readonly.
104
104
  def readonly?
105
105
  __selected_fields != nil
106
106
  end
@@ -110,7 +110,7 @@ module Mongoid
110
110
  # @example Is this settable?
111
111
  # person.settable?
112
112
  #
113
- # @return [ true, false ] Is this document a new embeds one?
113
+ # @return [ true | false ] Is this document a new embeds one?
114
114
  def settable?
115
115
  new_record? && embedded_one? && _parent.persisted?
116
116
  end
@@ -120,7 +120,7 @@ module Mongoid
120
120
  # @example Is the document updateable?
121
121
  # person.updateable?
122
122
  #
123
- # @return [ true, false ] If the document is changed and persisted.
123
+ # @return [ true | false ] If the document is changed and persisted.
124
124
  def updateable?
125
125
  persisted? && changed?
126
126
  end
@@ -36,7 +36,6 @@ module Mongoid
36
36
  # Mongoid::Tasks::Database.undefined_indexes
37
37
  #
38
38
  # @return [ Array<Hash> ] The list of undefined indexes by model.
39
- #
40
39
  def undefined_indexes(models = ::Mongoid.models)
41
40
  undefined_by_model = {}
42
41
 
@@ -90,7 +89,6 @@ module Mongoid
90
89
  # Mongoid::Tasks::Database.remove_indexes
91
90
  #
92
91
  # @return [ Array<Class> ] The un-indexed models.
93
- #
94
92
  def remove_indexes(models = ::Mongoid.models)
95
93
  models.each do |model|
96
94
  next if model.embedded?
@@ -37,7 +37,7 @@ module Mongoid
37
37
  # @example Is the current thread in assigning mode?
38
38
  # proxy._assigning?
39
39
  #
40
- # @return [ true, false ] If the thread is assigning.
40
+ # @return [ true | false ] If the thread is assigning.
41
41
  def _assigning?
42
42
  Threaded.executing?(ASSIGN)
43
43
  end
@@ -62,7 +62,7 @@ module Mongoid
62
62
  # @example Is the current thread in binding mode?
63
63
  # proxy.binding?
64
64
  #
65
- # @return [ true, false ] If the thread is binding.
65
+ # @return [ true | false ] If the thread is binding.
66
66
  def _binding?
67
67
  Threaded.executing?(BIND)
68
68
  end
@@ -87,7 +87,7 @@ module Mongoid
87
87
  # @example Is the current thread in building mode?
88
88
  # proxy._building?
89
89
  #
90
- # @return [ true, false ] If the thread is building.
90
+ # @return [ true | false ] If the thread is building.
91
91
  def _building?
92
92
  Threaded.executing?(BUILD)
93
93
  end
@@ -97,7 +97,7 @@ module Mongoid
97
97
  # @example Is the current thread in creating mode?
98
98
  # proxy.creating?
99
99
  #
100
- # @return [ true, false ] If the thread is creating.
100
+ # @return [ true | false ] If the thread is creating.
101
101
  def _creating?
102
102
  Threaded.executing?(CREATE)
103
103
  end
@@ -122,7 +122,7 @@ module Mongoid
122
122
  # @example Is the current thread in loading mode?
123
123
  # proxy._loading?
124
124
  #
125
- # @return [ true, false ] If the thread is loading.
125
+ # @return [ true | false ] If the thread is loading.
126
126
  def _loading?
127
127
  Threaded.executing?(LOAD)
128
128
  end
@@ -45,7 +45,7 @@ module Mongoid
45
45
  # @example Get the global database override.
46
46
  # Threaded.database_override
47
47
  #
48
- # @return [ String, Symbol ] The override.
48
+ # @return [ String | Symbol ] The override.
49
49
  def database_override
50
50
  Thread.current[DATABASE_OVERRIDE_KEY]
51
51
  end
@@ -55,9 +55,9 @@ module Mongoid
55
55
  # @example Set the global database override.
56
56
  # Threaded.database_override = :testing
57
57
  #
58
- # @param [ String, Symbol ] name The global override name.
58
+ # @param [ String | Symbol ] name The global override name.
59
59
  #
60
- # @return [ String, Symbol ] The override.
60
+ # @return [ String | Symbol ] The override.
61
61
  def database_override=(name)
62
62
  Thread.current[DATABASE_OVERRIDE_KEY] = name
63
63
  end
@@ -167,7 +167,7 @@ module Mongoid
167
167
  # @example Get the global client override.
168
168
  # Threaded.client_override
169
169
  #
170
- # @return [ String, Symbol ] The override.
170
+ # @return [ String | Symbol ] The override.
171
171
  def client_override
172
172
  Thread.current[CLIENT_OVERRIDE_KEY]
173
173
  end
@@ -177,9 +177,9 @@ module Mongoid
177
177
  # @example Set the global client override.
178
178
  # Threaded.client_override = :testing
179
179
  #
180
- # @param [ String, Symbol ] name The global override name.
180
+ # @param [ String | Symbol ] name The global override name.
181
181
  #
182
- # @return [ String, Symbol ] The override.
182
+ # @return [ String | Symbol ] The override.
183
183
  def client_override=(name)
184
184
  Thread.current[CLIENT_OVERRIDE_KEY] = name
185
185
  end
@@ -255,7 +255,7 @@ module Mongoid
255
255
  #
256
256
  # @param [ Document ] document The document to check.
257
257
  #
258
- # @return [ true, false ] If the document is autosaved.
258
+ # @return [ true | false ] If the document is autosaved.
259
259
  def autosaved?(document)
260
260
  autosaves_for(document.class).include?(document._id)
261
261
  end
@@ -267,7 +267,7 @@ module Mongoid
267
267
  #
268
268
  # @param [ Document ] document The document to check.
269
269
  #
270
- # @return [ true, false ] If the document is validated.
270
+ # @return [ true | false ] If the document is validated.
271
271
  def validated?(document)
272
272
  validations_for(document.class).include?(document._id)
273
273
  end
@@ -330,7 +330,7 @@ module Mongoid
330
330
  # @example Get the session for this thread.
331
331
  # Threaded.get_session
332
332
  #
333
- # @return [ Mongo::Session, nil ] The session cached on this thread or nil.
333
+ # @return [ Mongo::Session | nil ] The session cached on this thread or nil.
334
334
  def get_session
335
335
  Thread.current[:session]
336
336
  end
@@ -35,7 +35,7 @@ module Mongoid
35
35
  # @example Can the timestamp be set?
36
36
  # document.able_to_set_updated_at?
37
37
  #
38
- # @return [ true, false ] If the timestamp can be set.
38
+ # @return [ true | false ] If the timestamp can be set.
39
39
  def able_to_set_updated_at?
40
40
  !frozen? && !timeless? && (new_record? || changed?)
41
41
  end
@@ -203,7 +203,7 @@ module Mongoid
203
203
  # @example Check if the document is a subclass
204
204
  # Square.new.hereditary?
205
205
  #
206
- # @return [ true, false ] True if hereditary, false if not.
206
+ # @return [ true | false ] True if hereditary, false if not.
207
207
  def hereditary?
208
208
  self.class.hereditary?
209
209
  end
@@ -283,7 +283,7 @@ module Mongoid
283
283
  # @example Is the document the root?
284
284
  # document._root?
285
285
  #
286
- # @return [ true, false ] If the document is the root.
286
+ # @return [ true | false ] If the document is the root.
287
287
  def _root?
288
288
  _parent ? false : true
289
289
  end
@@ -295,7 +295,7 @@ module Mongoid
295
295
  # @example Check if the document is a subclass.
296
296
  # Square.hereditary?
297
297
  #
298
- # @return [ true, false ] True if hereditary, false if not.
298
+ # @return [ true | false ] True if hereditary, false if not.
299
299
  def hereditary?
300
300
  !!(Mongoid::Document > superclass)
301
301
  end
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # validator.validate_each(model, :name, "value")
13
13
  #
14
14
  # @param [ Document ] document The document.
15
- # @param [ Symbol, String ] attribute The attribute to validate.
15
+ # @param [ Symbol | String ] attribute The attribute to validate.
16
16
  # @param [ Object ] value The attribute value.
17
17
  def validate_each(document, attribute, value)
18
18
  field = document.fields[document.database_field_name(attribute)]
@@ -19,7 +19,6 @@ module Mongoid
19
19
  # end
20
20
  #
21
21
  # @param [ Array ] args The arguments to pass to the validator.
22
- #
23
22
  def validates_associated(*args)
24
23
  validates_with(AssociatedValidator, _merge_attributes(args))
25
24
  end
@@ -37,7 +36,6 @@ module Mongoid
37
36
  # end
38
37
  #
39
38
  # @param [ Array ] args The arguments to pass to the validator.
40
- #
41
39
  def validates_uniqueness_of(*args)
42
40
  validates_with(UniquenessValidator, _merge_attributes(args))
43
41
  end
@@ -56,7 +56,7 @@ module Mongoid
56
56
  # @param [ Symbol ] attr The attribute.
57
57
  # @param [ Object ] value The value.
58
58
  #
59
- # @return [ true, false ] If the doc is missing.
59
+ # @return [ true | false ] If the doc is missing.
60
60
  def relation_or_fk_missing?(doc, attr, value)
61
61
  return true if value.blank? && doc.send(attr).blank?
62
62
  association = doc.relations[attr.to_s]
@@ -72,7 +72,7 @@ module Mongoid
72
72
  #
73
73
  # @param [ Object ] value The value.
74
74
  #
75
- # @return [ true, false ] If the value is not present.
75
+ # @return [ true | false ] If the value is not present.
76
76
  def not_present?(value)
77
77
  value.blank? && value != false
78
78
  end
@@ -74,7 +74,7 @@ module Mongoid
74
74
  # @example Is the validation case sensitive?
75
75
  # validator.case_sensitive?
76
76
  #
77
- # @return [ true, false ] If the validation is case sensitive.
77
+ # @return [ true | false ] If the validation is case sensitive.
78
78
  def case_sensitive?
79
79
  !(options[:case_sensitive] == false)
80
80
  end
@@ -86,7 +86,7 @@ module Mongoid
86
86
  # @example Create the criteria.
87
87
  # validator.create_criteria(User, user, :name, "syd")
88
88
  #
89
- # @param [ Class, Proxy ] base The base to execute the criteria from.
89
+ # @param [ Class | Proxy ] base The base to execute the criteria from.
90
90
  # @param [ Document ] document The document to validate.
91
91
  # @param [ Symbol ] attribute The name of the attribute.
92
92
  # @param [ Object ] value The value of the object.
@@ -149,7 +149,7 @@ module Mongoid
149
149
  #
150
150
  # @param [ Object ] value The value to filter.
151
151
  #
152
- # @return [ Object, Regexp ] The value, filtered or not.
152
+ # @return [ Object | Regexp ] The value, filtered or not.
153
153
  def filter(value)
154
154
  !case_sensitive? && value ? /\A#{Regexp.escape(value.to_s)}\z/i : value
155
155
  end
@@ -182,7 +182,7 @@ module Mongoid
182
182
  #
183
183
  # @param [ Document ] document The embedded document.
184
184
  #
185
- # @return [ true, false ] If the validation should be skipped.
185
+ # @return [ true | false ] If the validation should be skipped.
186
186
  def skip_validation?(document)
187
187
  !document._parent || document.embedded_one?
188
188
  end
@@ -196,7 +196,7 @@ module Mongoid
196
196
  #
197
197
  # @param [ Document ] document The embedded document.
198
198
  #
199
- # @return [ true, false ] If the scope reference has changed.
199
+ # @return [ true | false ] If the scope reference has changed.
200
200
  def scope_value_changed?(document)
201
201
  Array.wrap(options[:scope]).any? do |item|
202
202
  document.send("attribute_changed?", item.to_s)
@@ -278,7 +278,7 @@ module Mongoid
278
278
  # @param [ Document ] document The document getting validated.
279
279
  # @param [ Symbol ] attribute The attribute to validate.
280
280
  #
281
- # @return [ true, false ] If we need to validate.
281
+ # @return [ true | false ] If we need to validate.
282
282
  def validation_required?(document, attribute)
283
283
  document.new_record? ||
284
284
  document.send("attribute_changed?", attribute.to_s) ||
@@ -295,7 +295,7 @@ module Mongoid
295
295
  # @param [ Document ] document The document getting validated.
296
296
  # @param [ Symbol ] attribute The attribute to validate.
297
297
  #
298
- # @return [ true, false ] If the attribute is localized.
298
+ # @return [ true | false ] If the attribute is localized.
299
299
  def localized?(document, attribute)
300
300
  document.fields[document.database_field_name(attribute)].try(:localized?)
301
301
  end
@@ -44,7 +44,7 @@ module Mongoid
44
44
  #
45
45
  # @param [ Hash ] options The options to check.
46
46
  #
47
- # @return [ true, false ] If we are validating.
47
+ # @return [ true | false ] If we are validating.
48
48
  def performing_validations?(options = {})
49
49
  options[:validate].nil? ? true : options[:validate]
50
50
  end
@@ -83,7 +83,7 @@ module Mongoid
83
83
  #
84
84
  # @param [ Symbol ] context The optional validation context.
85
85
  #
86
- # @return [ true, false ] True if valid, false if not.
86
+ # @return [ true | false ] True if valid, false if not.
87
87
  def valid?(context = nil)
88
88
  super context ? context : (new_record? ? :create : :update)
89
89
  end
@@ -93,7 +93,7 @@ module Mongoid
93
93
  # @example Is the document validated?
94
94
  # document.validated?
95
95
  #
96
- # @return [ true, false ] Has the document already been validated?
96
+ # @return [ true | false ] Has the document already been validated?
97
97
  def validated?
98
98
  Threaded.validated?(self)
99
99
  end
@@ -103,7 +103,7 @@ module Mongoid
103
103
  # @example Are we validating with a query?
104
104
  # document.validating_with_query?
105
105
  #
106
- # @return [ true, false ] If we are validating with a query.
106
+ # @return [ true | false ] If we are validating with a query.
107
107
  def validating_with_query?
108
108
  self.class.validating_with_query?
109
109
  end
@@ -129,7 +129,7 @@ module Mongoid
129
129
  # @example Validate with a specific validator.
130
130
  # validates_with MyValidator, on: :create
131
131
  #
132
- # @param [ Class<Array>, Hash ] args The validator classes and options.
132
+ # @param [ Class<Array> | Hash ] args The validator classes and options.
133
133
  #
134
134
  # @note See ActiveModel::Validations::With for full options. This is
135
135
  # overridden to add autosave functionality when presence validation is
@@ -151,7 +151,7 @@ module Mongoid
151
151
  # @example Are we validating with a query?
152
152
  # Model.validating_with_query?
153
153
  #
154
- # @return [ true, false ] If we are validating with a query.
154
+ # @return [ true | false ] If we are validating with a query.
155
155
  def validating_with_query?
156
156
  Threaded.executing?("#{name}-validate-with-query")
157
157
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mongoid
4
- VERSION = "8.0.1"
4
+ VERSION = "8.0.2"
5
5
  end
@@ -85,8 +85,8 @@ describe Mongoid::Equality do
85
85
 
86
86
  describe ".===" do
87
87
 
88
- context "when legacy_triple_equals is set" do
89
- config_override :legacy_triple_equals, true
88
+ context "when legacy_triple_equals is not set" do
89
+ config_override :legacy_triple_equals, false
90
90
 
91
91
  context "when comparable is an instance of this document" do
92
92
 
@@ -128,8 +128,8 @@ describe Mongoid::Equality do
128
128
  end
129
129
  end
130
130
 
131
- context "when legacy_triple_equals is not set" do
132
- config_override :legacy_triple_equals, false
131
+ context "when legacy_triple_equals is set" do
132
+ config_override :legacy_triple_equals, true
133
133
 
134
134
  context "when comparable is an instance of this document" do
135
135
 
@@ -205,8 +205,8 @@ describe Mongoid::Equality do
205
205
 
206
206
  context "when the class is the same" do
207
207
 
208
- it "returns false" do
209
- expect(person === Person).to be false
208
+ it "returns true" do
209
+ expect(person === Person).to be true
210
210
  end
211
211
  end
212
212
 
@@ -219,8 +219,8 @@ describe Mongoid::Equality do
219
219
 
220
220
  context "when the class is a superclass" do
221
221
 
222
- it "returns false" do
223
- expect(Doctor.new === Person).to be false
222
+ it "returns true" do
223
+ expect(Doctor.new === Person).to be true
224
224
  end
225
225
  end
226
226
  end
@@ -256,8 +256,8 @@ describe Mongoid::Equality do
256
256
  context "when comparing to a class" do
257
257
  context "when the class is the same" do
258
258
 
259
- it "returns true" do
260
- expect(person === Person).to be true
259
+ it "returns false" do
260
+ expect(person === Person).to be false
261
261
  end
262
262
  end
263
263
 
@@ -270,8 +270,8 @@ describe Mongoid::Equality do
270
270
 
271
271
  context "when the class is a superclass" do
272
272
 
273
- it "returns true" do
274
- expect(Doctor.new === Person).to be true
273
+ it "returns false" do
274
+ expect(Doctor.new === Person).to be false
275
275
  end
276
276
  end
277
277
  end