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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4aba01720c23aaef7cb2c1ca3045e351a3499bb80758f4ddbdf2cc15baa9cd4
4
- data.tar.gz: '082d09a7a072d85b8a19f884efc7805107732a32f0e90fe953785eabfae25bb7'
3
+ metadata.gz: 9c2c1f57188d73b1d7f6d965b01a05cd97ddab316855221e6b23f70858e820af
4
+ data.tar.gz: 0ad8309b683b8031796d3e3d99c36840481b7b2cc8aa773e32c4d1b050380671
5
5
  SHA512:
6
- metadata.gz: 35fedeedf4ad08f7f250600101eab0af7460e2b1c727448d0e880e418b195a18c33c8b672f2472e8291d2984d13e0781f271d8b034fab0753a80a7a76e62e6fd
7
- data.tar.gz: f5da886e2b77b820c4d8928edc3c9f19d090712e17fd2efc484af0e13cd1e659dbf6f19270e4c53462779536e8b924b9cc65da3aeeed65cd98a1a5fbcb1e1649
6
+ metadata.gz: 00ca56917eafe55f9b4ef394569ac8a64023c67906fdd65522d74a95046a7cacab42ca11baea2917e80f803cadc9c7d484e170227fcdf48a14a8656e96639fdb
7
+ data.tar.gz: 159b5215f615ca52777a81127e8312767d4e66adbb77e047d01769ed90281ef4959de4bda42e5ce2eadd9803e4a3d11f5d3d50c8da467241f3dd16bd90f69226
checksums.yaml.gz.sig CHANGED
Binary file
@@ -238,6 +238,7 @@ en:
238
238
  \_\_language_override\n
239
239
  \_\_default_language\n
240
240
  \_\_collation\n
241
+ \_\_wildcard_projection: { 'path.to.field.a': 1, 'path.to.field.b': 0 }\n
241
242
  Valid types are: 1, -1, '2d', '2dsphere', 'geoHaystack (deprecated)', 'text', 'hashed'\n\n
242
243
  Example:\n
243
244
  \_\_class Band\n
@@ -15,8 +15,8 @@ module Mongoid
15
15
  # @example Build the association.
16
16
  # person.__build__(:addresses, { :_id => 1 }, association)
17
17
  #
18
- # @param [ String, Symbol ] name The name of the association.
19
- # @param [ Hash, BSON::ObjectId ] object The id or attributes to use.
18
+ # @param [ String | Symbol ] name The name of the association.
19
+ # @param [ Hash | BSON::ObjectId ] object The id or attributes to use.
20
20
  # @param [ Association ] association The association metadata.
21
21
  # @param [ Hash ] selected_fields Fields which were retrieved via #only.
22
22
  # If selected_fields is specified, fields not listed in it will not be
@@ -33,7 +33,7 @@ module Mongoid
33
33
  # @example Create the association.
34
34
  # person.create_relation(document, association)
35
35
  #
36
- # @param [ Document, Array<Document> ] object The association target.
36
+ # @param [ Document | Array<Document> ] object The association target.
37
37
  # @param [ Association ] association The association metadata.
38
38
  # @param [ Hash ] selected_fields Fields which were retrieved via #only.
39
39
  # If selected_fields is specified, fields not listed in it will not be
@@ -80,7 +80,7 @@ module Mongoid
80
80
  # @example Set the proxy on the document.
81
81
  # person.set(:addresses, addresses)
82
82
  #
83
- # @param [ String, Symbol ] name The name of the association.
83
+ # @param [ String | Symbol ] name The name of the association.
84
84
  # @param [ Proxy ] relation The association to set.
85
85
  #
86
86
  # @return [ Proxy ] The association.
@@ -101,7 +101,7 @@ module Mongoid
101
101
  # @param [ Symbol ] name The name of the association.
102
102
  # @param [ Association ] association The association metadata.
103
103
  # @param [ Object ] object The object used to build the association.
104
- # @param [ true, false ] reload If the association is to be reloaded.
104
+ # @param [ true | false ] reload If the association is to be reloaded.
105
105
  #
106
106
  # @return [ Proxy ] The association.
107
107
  def get_relation(name, association, object, reload = false)
@@ -225,7 +225,7 @@ module Mongoid
225
225
  # @example Is autobuild disabled?
226
226
  # document.without_autobuild?
227
227
  #
228
- # @return [ true, false ] If autobuild is disabled.
228
+ # @return [ true | false ] If autobuild is disabled.
229
229
  def without_autobuild?
230
230
  Threaded.executing?(:without_autobuild)
231
231
  end
@@ -15,7 +15,7 @@ module Mongoid
15
15
  # Binding.new(base, target, association)
16
16
  #
17
17
  # @param [ Document ] base The base of the binding.
18
- # @param [ Document, Array<Document> ] target The target of the binding.
18
+ # @param [ Document | Array<Document> ] target The target of the binding.
19
19
  # @param [ Association ] association The association metadata.
20
20
  def initialize(base, target, association)
21
21
  @_base, @_target, @_association = base, target, association
@@ -200,7 +200,7 @@ module Mongoid
200
200
  # @example Set the base association.
201
201
  # binding.set_base_association
202
202
  #
203
- # @return [ true, false ] If the association changed.
203
+ # @return [ true | false ] If the association changed.
204
204
  def set_base_association
205
205
  inverse_association = _association.inverse_association(_target)
206
206
  if inverse_association != _association && !inverse_association.nil?
@@ -5,7 +5,6 @@ module Mongoid
5
5
 
6
6
  # Used for converting foreign key values to the correct type based on the
7
7
  # types of ids that the document stores.
8
- #
9
8
  module Constrainable
10
9
 
11
10
  # Convert the supplied object to the appropriate type to set as the
@@ -196,7 +196,7 @@ module Mongoid
196
196
  # @example Can inserts be performed?
197
197
  # batchable.insertable?
198
198
  #
199
- # @return [ true, false ] If inserts can be performed.
199
+ # @return [ true | false ] If inserts can be performed.
200
200
  def insertable?
201
201
  persistable? && !_assigning? && inserts_valid
202
202
  end
@@ -208,7 +208,7 @@ module Mongoid
208
208
  # @example Are the inserts currently valid.
209
209
  # batchable.inserts_valid
210
210
  #
211
- # @return [ true, false ] If inserts are currently valid.
211
+ # @return [ true | false ] If inserts are currently valid.
212
212
  def inserts_valid
213
213
  @inserts_valid
214
214
  end
@@ -220,9 +220,9 @@ module Mongoid
220
220
  # @example Set the flag.
221
221
  # batchable.inserts_valid = true
222
222
  #
223
- # @param [ true, false ] value The flag.
223
+ # @param [ true | false ] value The flag.
224
224
  #
225
- # @return [ true, false ] The flag.
225
+ # @return [ true | false ] The flag.
226
226
  def inserts_valid=(value)
227
227
  @inserts_valid = value
228
228
  end
@@ -235,7 +235,7 @@ module Mongoid
235
235
  # @example Normalize the docs.
236
236
  # batchable.normalize_docs(docs)
237
237
  #
238
- # @param [ Array<Hash, Document> ] docs The docs to normalize.
238
+ # @param [ Array<Hash | Document> ] docs The docs to normalize.
239
239
  #
240
240
  # @return [ Array<Document> ] The docs.
241
241
  def normalize_docs(docs)
@@ -88,7 +88,7 @@ module Mongoid
88
88
  # @example Determine the child name.
89
89
  # Role.cyclic_child_name
90
90
  #
91
- # @param [ true, false ] many Is the a many association?
91
+ # @param [ true | false ] many Is the a many association?
92
92
  #
93
93
  # @return [ String ] "child_" plus the class name underscored in
94
94
  # singular or plural form.
@@ -32,7 +32,7 @@ module Mongoid
32
32
  #
33
33
  # @param [ Document ] replacement A document to replace the target.
34
34
  #
35
- # @return [ Document, nil ] The association or nil.
35
+ # @return [ Document | nil ] The association or nil.
36
36
  def substitute(replacement)
37
37
  unbind_one
38
38
  unless replacement
@@ -74,7 +74,7 @@ module Mongoid
74
74
  # @example Can we persist the association?
75
75
  # relation.persistable?
76
76
  #
77
- # @return [ true, false ] If the association is persistable.
77
+ # @return [ true | false ] If the association is persistable.
78
78
  def persistable?
79
79
  _target.persisted? && !_binding? && !_building?
80
80
  end
@@ -75,7 +75,7 @@ module Mongoid
75
75
 
76
76
  # Is this association polymorphic?
77
77
  #
78
- # @return [ true, false ] Whether this association is polymorphic.
78
+ # @return [ true | false ] Whether this association is polymorphic.
79
79
  def polymorphic?
80
80
  !!@options[:polymorphic]
81
81
  end
@@ -19,7 +19,7 @@ module Mongoid
19
19
  # @example Push a document.
20
20
  # person.addresses.push(address)
21
21
  #
22
- # @param [ Document, Array<Document> ] args Any number of documents.
22
+ # @param [ Document | Array<Document> ] args Any number of documents.
23
23
  def <<(*args)
24
24
  docs = args.flatten
25
25
  return concat(docs) if docs.size > 1
@@ -117,7 +117,7 @@ module Mongoid
117
117
  # @example Use #persisted? inside block to count persisted documents.
118
118
  # person.addresses.count { |a| a.persisted? && a.country == "FR" }
119
119
  #
120
- # @param [ Object, Array<Object> ] args Args to delegate to the target.
120
+ # @param [ Object | Array<Object> ] args Args to delegate to the target.
121
121
  #
122
122
  # @return [ Integer ] The total number of persisted embedded docs, as
123
123
  # flagged by the #persisted? method.
@@ -135,7 +135,7 @@ module Mongoid
135
135
  #
136
136
  # @param [ Document ] document The document to be deleted.
137
137
  #
138
- # @return [ Document, nil ] The deleted document or nil if nothing deleted.
138
+ # @return [ Document | nil ] The deleted document or nil if nothing deleted.
139
139
  def delete(document)
140
140
  execute_callbacks_around(:remove, document) do
141
141
  doc = _target.delete_one(document)
@@ -176,7 +176,7 @@ module Mongoid
176
176
  # doc.state == "GA"
177
177
  # end
178
178
  #
179
- # @return [ Many, Enumerator ] The association or an enumerator if no
179
+ # @return [ Many | Enumerator ] The association or an enumerator if no
180
180
  # block was provided.
181
181
  def delete_if
182
182
  if block_given?
@@ -210,7 +210,7 @@ module Mongoid
210
210
  # @example Are there persisted documents?
211
211
  # person.posts.exists?
212
212
  #
213
- # @return [ true, false ] True is persisted documents exist, false if not.
213
+ # @return [ true | false ] True is persisted documents exist, false if not.
214
214
  def exists?
215
215
  _target.any? { |doc| doc.persisted? }
216
216
  end
@@ -287,7 +287,7 @@ module Mongoid
287
287
  # @param [ Integer ] count The number of documents to pop, or 1 if not
288
288
  # provided.
289
289
  #
290
- # @return [ Document, Array<Document> ] The popped document(s).
290
+ # @return [ Document | Array<Document> ] The popped document(s).
291
291
  def pop(count = nil)
292
292
  if count
293
293
  if docs = _target[_target.size - count, _target.size]
@@ -312,7 +312,7 @@ module Mongoid
312
312
  # @param [ Integer ] count The number of documents to shift, or 1 if not
313
313
  # provided.
314
314
  #
315
- # @return [ Document, Array<Document> ] The shifted document(s).
315
+ # @return [ Document | Array<Document> ] The shifted document(s).
316
316
  def shift(count = nil)
317
317
  if count
318
318
  if _target.size > 0 && docs = _target[0, count]
@@ -429,7 +429,7 @@ module Mongoid
429
429
  #
430
430
  # If the method exists on the array, use the default proxy behavior.
431
431
  #
432
- # @param [ Symbol, String ] name The name of the method.
432
+ # @param [ Symbol | String ] name The name of the method.
433
433
  # @param [ Array ] args The method args
434
434
  # @param [ Proc ] block Optional block to pass.
435
435
  #
@@ -446,7 +446,7 @@ module Mongoid
446
446
  # @example Can we persist the association?
447
447
  # relation.persistable?
448
448
  #
449
- # @return [ true, false ] If the association is persistable.
449
+ # @return [ true | false ] If the association is persistable.
450
450
  def persistable?
451
451
  _base.persisted? && !_binding?
452
452
  end
@@ -490,7 +490,7 @@ module Mongoid
490
490
  # relation.remove_all({ :num => 1 }, true)
491
491
  #
492
492
  # @param [ Hash ] conditions Conditions to filter by.
493
- # @param [ true, false ] method :delete or :destroy.
493
+ # @param [ true | false ] method :delete or :destroy.
494
494
  #
495
495
  # @return [ Integer ] The number of documents removed.
496
496
  def remove_all(conditions = {}, method = :delete)
@@ -92,7 +92,7 @@ module Mongoid
92
92
 
93
93
  # Is this association polymorphic?
94
94
  #
95
- # @return [ true, false ] Whether this association is polymorphic.
95
+ # @return [ true | false ] Whether this association is polymorphic.
96
96
  def polymorphic?
97
97
  @polymorphic ||= !!@options[:as]
98
98
  end
@@ -101,7 +101,7 @@ module Mongoid
101
101
  #
102
102
  # @note Only relevant if the association is polymorphic.
103
103
  #
104
- # @return [ String, nil ] The field for storing the associated object's type.
104
+ # @return [ String | nil ] The field for storing the associated object's type.
105
105
  def type
106
106
  @type ||= "#{as}_type" if polymorphic?
107
107
  end
@@ -45,7 +45,7 @@ module Mongoid
45
45
  #
46
46
  # @param [ Document ] replacement A document to replace the target.
47
47
  #
48
- # @return [ Document, nil ] The association or nil.
48
+ # @return [ Document | nil ] The association or nil.
49
49
  def substitute(replacement)
50
50
  if replacement != self
51
51
  if _assigning?
@@ -112,7 +112,7 @@ module Mongoid
112
112
  # @example Can we persist the association?
113
113
  # relation.persistable?
114
114
  #
115
- # @return [ true, false ] If the association is persistable.
115
+ # @return [ true | false ] If the association is persistable.
116
116
  def persistable?
117
117
  _base.persisted? && !_binding? && !_building? && !_assigning?
118
118
  end
@@ -66,7 +66,7 @@ module Mongoid
66
66
  # @example Get the validation default.
67
67
  # Proxy.validation_default
68
68
  #
69
- # @return [ true, false ] The validation default.
69
+ # @return [ true | false ] The validation default.
70
70
  def validation_default; true; end
71
71
 
72
72
  # Does this association type store the foreign key?
@@ -88,7 +88,7 @@ module Mongoid
88
88
 
89
89
  # Is this association polymorphic?
90
90
  #
91
- # @return [ true, false ] Whether this association is polymorphic.
91
+ # @return [ true | false ] Whether this association is polymorphic.
92
92
  def polymorphic?
93
93
  @polymorphic ||= !!@options[:as]
94
94
  end
@@ -97,7 +97,7 @@ module Mongoid
97
97
  #
98
98
  # @note Only relevant if the association is polymorphic.
99
99
  #
100
- # @return [ String, nil ] The field for storing the associated object's type.
100
+ # @return [ String | nil ] The field for storing the associated object's type.
101
101
  def type
102
102
  @type ||= "#{as}_type" if polymorphic?
103
103
  end
@@ -17,7 +17,7 @@ module Mongoid
17
17
  # @example Is the association empty??
18
18
  # person.addresses.blank?
19
19
  #
20
- # @return [ true, false ] If the association is empty or not.
20
+ # @return [ true | false ] If the association is empty or not.
21
21
  def blank?
22
22
  !any?
23
23
  end
@@ -28,7 +28,6 @@ module Mongoid
28
28
  # @example Create and save the new document.
29
29
  # person.posts.create(:text => "Testing")
30
30
  #
31
- #
32
31
  # @param [ Hash ] attributes The attributes to create with.
33
32
  # @param [ Class ] type The optional type of document to create.
34
33
  #
@@ -131,9 +130,9 @@ module Mongoid
131
130
  # relation.respond_to?(:name)
132
131
  #
133
132
  # @param [ Symbol ] name The method name.
134
- # @param [ true, false ] include_private Whether to include private methods.
133
+ # @param [ true | false ] include_private Whether to include private methods.
135
134
  #
136
- # @return [ true, false ] If the proxy responds to the method.
135
+ # @return [ true | false ] If the proxy responds to the method.
137
136
  def respond_to?(name, include_private = false)
138
137
  [].respond_to?(name, include_private) ||
139
138
  klass.respond_to?(name, include_private) || super
@@ -158,9 +157,9 @@ module Mongoid
158
157
  #
159
158
  # @param [ Hash ] options The options to pass.
160
159
  #
161
- # @option options [ Symbol ] :include What associations to include
162
- # @option options [ Symbol ] :only Limit the fields to only these.
163
- # @option options [ Symbol ] :except Dont include these fields.
160
+ # @option options [ Symbol | String | Array<Symbol | String> ] :except Do not include these field(s).
161
+ # @option options [ Symbol | String | Array<Symbol | String> ] :include Which association(s) to include.
162
+ # @option options [ Symbol | String | Array<Symbol | String> ] :only Limit the field(s) to only these.
164
163
  #
165
164
  # @return [ Hash ] The documents, ready to be serialized.
166
165
  def serializable_hash(options = {})
@@ -65,7 +65,7 @@ module Mongoid
65
65
  #
66
66
  # @param [ Hash ] attributes The attributes to pull the flag from.
67
67
  #
68
- # @return [ true, false ] If the association can potentially be deleted.
68
+ # @return [ true | false ] If the association can potentially be deleted.
69
69
  def destroyable?(attributes)
70
70
  destroy = attributes.delete(:_destroy)
71
71
  Nested::DESTROY_FLAGS.include?(destroy) && allow_destroy?
@@ -79,7 +79,7 @@ module Mongoid
79
79
  #
80
80
  # @param [ Hash ] attributes The attributes being set.
81
81
  #
82
- # @return [ true, false ] If the attributes exceed the limit.
82
+ # @return [ true | false ] If the attributes exceed the limit.
83
83
  def over_limit?(attributes)
84
84
  limit = options[:limit]
85
85
  limit ? attributes.size > limit : false
@@ -165,7 +165,7 @@ module Mongoid
165
165
  # builder.update_nested_relation(parent, id, attrs)
166
166
  #
167
167
  # @param [ Document ] parent The parent document.
168
- # @param [ String, BSON::ObjectId ] id of the related document.
168
+ # @param [ String | BSON::ObjectId ] id of the related document.
169
169
  # @param [ Hash ] attrs The single document attributes to process.
170
170
  def update_nested_relation(parent, id, attrs)
171
171
  first = existing.first
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Do we allow a destroy?
13
13
  # builder.allow_destroy?
14
14
  #
15
- # @return [ true, false ] True if the allow destroy option was set.
15
+ # @return [ true | false ] True if the allow destroy option was set.
16
16
  def allow_destroy?
17
17
  options[:allow_destroy] || false
18
18
  end
@@ -25,7 +25,7 @@ module Mongoid
25
25
  # @param [ Document ] document The parent document of the association
26
26
  # @param [ Hash ] attrs The attributes to check for rejection.
27
27
  #
28
- # @return [ true, false ] True and call proc or method if rejectable, false if not.
28
+ # @return [ true | false ] True and call proc or method if rejectable, false if not.
29
29
  def reject?(document, attrs)
30
30
  case callback = options[:reject_if]
31
31
  when Symbol
@@ -43,7 +43,7 @@ module Mongoid
43
43
  # @example Is this update only?
44
44
  # builder.update_only?
45
45
  #
46
- # @return [ true, false ] True if the update_only option was set.
46
+ # @return [ true | false ] True if the update_only option was set.
47
47
  def update_only?
48
48
  options[:update_only] || false
49
49
  end
@@ -56,7 +56,7 @@ module Mongoid
56
56
  # @param [ Class ] klass The class we're trying to convert for.
57
57
  # @param [ String ] id The id, usually coming from the form.
58
58
  #
59
- # @return [ BSON::ObjectId, String, Object ] The converted id.
59
+ # @return [ BSON::ObjectId | String | Object ] The converted id.
60
60
  def convert_id(klass, id)
61
61
  klass.using_object_ids? ? BSON::ObjectId.mongoize(id) : id
62
62
  end
@@ -62,7 +62,7 @@ module Mongoid
62
62
  # @example Is the id acceptable?
63
63
  # one.acceptable_id?
64
64
  #
65
- # @return [ true, false ] If the id part of the logic will allow an update.
65
+ # @return [ true | false ] If the id part of the logic will allow an update.
66
66
  def acceptable_id?
67
67
  id = association.klass.extract_id_field(attributes)
68
68
  id = convert_id(existing.class, id)
@@ -74,7 +74,7 @@ module Mongoid
74
74
  # @example Can the existing object be deleted?
75
75
  # one.delete?
76
76
  #
77
- # @return [ true, false ] If the association should be deleted.
77
+ # @return [ true | false ] If the association should be deleted.
78
78
  def delete?
79
79
  id = association.klass.extract_id_field(attributes)
80
80
  destroyable? && !id.nil?
@@ -85,7 +85,7 @@ module Mongoid
85
85
  # @example Is the object destroyable?
86
86
  # one.destroyable?({ :_destroy => "1" })
87
87
  #
88
- # @return [ true, false ] If the association can potentially be
88
+ # @return [ true | false ] If the association can potentially be
89
89
  # destroyed.
90
90
  def destroyable?
91
91
  Nested::DESTROY_FLAGS.include?(destroy) && allow_destroy?
@@ -96,7 +96,7 @@ module Mongoid
96
96
  # @example Is the document to be replaced?
97
97
  # one.replace?
98
98
  #
99
- # @return [ true, false ] If the document should be replaced.
99
+ # @return [ true | false ] If the document should be replaced.
100
100
  def replace?
101
101
  !existing && !destroyable? && !attributes.blank?
102
102
  end
@@ -106,7 +106,7 @@ module Mongoid
106
106
  # @example Should the document be updated?
107
107
  # one.update?
108
108
  #
109
- # @return [ true, false ] If the object should have its attributes updated.
109
+ # @return [ true | false ] If the object should have its attributes updated.
110
110
  def update?
111
111
  existing && !destroyable? && acceptable_id?
112
112
  end
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Clear the relation.
13
13
  # relation.clear
14
14
  #
15
- # @return [ true, false ] If the delete succeeded.
15
+ # @return [ true | false ] If the delete succeeded.
16
16
  def clear
17
17
  _target.delete
18
18
  end
@@ -34,7 +34,7 @@ module Mongoid
34
34
  #
35
35
  # @param [ Symbol ] name The method name.
36
36
  #
37
- # @return [ true, false ] If the proxy responds to the method.
37
+ # @return [ true | false ] If the proxy responds to the method.
38
38
  def respond_to?(name, include_private = false)
39
39
  _target.respond_to?(name, include_private) || super
40
40
  end
@@ -7,7 +7,7 @@ module Mongoid
7
7
 
8
8
  # Returns the name of the parent to a polymorphic child.
9
9
  #
10
- # @return [ String, Symbol ] The name.
10
+ # @return [ String | Symbol ] The name.
11
11
  def as
12
12
  @options[:as]
13
13
  end
@@ -28,21 +28,21 @@ module Mongoid
28
28
 
29
29
  # Whether to index the primary or foreign key field.
30
30
  #
31
- # @return [ true, false ]
31
+ # @return [ true | false ]
32
32
  def indexed?
33
33
  @indexed ||= !!@options[:index]
34
34
  end
35
35
 
36
36
  # Whether the association is autobuilding.
37
37
  #
38
- # @return [ true, false ]
38
+ # @return [ true | false ]
39
39
  def autobuilding?
40
40
  !!@options[:autobuild]
41
41
  end
42
42
 
43
43
  # Is the association cyclic.
44
44
  #
45
- # @return [ true, false ] Whether the association is cyclic.
45
+ # @return [ true | false ] Whether the association is cyclic.
46
46
  def cyclic?
47
47
  !!@options[:cyclic]
48
48
  end
@@ -57,7 +57,7 @@ module Mongoid
57
57
  # Mongoid assumes that the field used to hold the primary key of the association is id.
58
58
  # You can override this and explicitly specify the primary key with the :primary_key option.
59
59
  #
60
- # @return [ Symbol, String ] The primary key.
60
+ # @return [ Symbol | String ] The primary key.
61
61
  def primary_key
62
62
  @primary_key ||= @options[:primary_key] ? @options[:primary_key].to_s : Relatable::PRIMARY_KEY_DEFAULT
63
63
  end
@@ -65,7 +65,7 @@ module Mongoid
65
65
  # Options to save any loaded members and destroy members that are marked for destruction
66
66
  # when the parent object is saved.
67
67
  #
68
- # @return [ true, false ] The autosave option.
68
+ # @return [ true | false ] The autosave option.
69
69
  def autosave
70
70
  !!@options[:autosave]
71
71
  end
@@ -73,19 +73,19 @@ module Mongoid
73
73
 
74
74
  # Whether the association is counter-cached.
75
75
  #
76
- # @return [ true, false ]
76
+ # @return [ true | false ]
77
77
  def counter_cached?
78
78
  !!@options[:counter_cache]
79
79
  end
80
80
 
81
81
  # Whether this association is polymorphic.
82
82
  #
83
- # @return [ true, false ] Whether the association is polymorphic.
83
+ # @return [ true | false ] Whether the association is polymorphic.
84
84
  def polymorphic?; false; end
85
85
 
86
86
  # Whether the association has callbacks cascaded down from the parent.
87
87
  #
88
- # @return [ true, false ] Whether callbacks are cascaded.
88
+ # @return [ true | false ] Whether callbacks are cascaded.
89
89
  def cascading_callbacks?
90
90
  !!@options[:cascade_callbacks]
91
91
  end
@@ -48,7 +48,7 @@ module Mongoid
48
48
  # proxy.init(person, name, association)
49
49
  #
50
50
  # @param [ Document ] base The base document on the proxy.
51
- # @param [ Document, Array<Document> ] target The target of the proxy.
51
+ # @param [ Document | Array<Document> ] target The target of the proxy.
52
52
  # @param [ Association ] association The association metadata.
53
53
  def init(base, target, association)
54
54
  @_base, @_target, @_association = base, target, association
@@ -117,9 +117,8 @@ module Mongoid
117
117
  # Default behavior of method missing should be to delegate all calls
118
118
  # to the target of the proxy. This can be overridden in special cases.
119
119
  #
120
- # @param [ String, Symbol ] name The name of the method.
120
+ # @param [ String | Symbol ] name The name of the method.
121
121
  # @param [ Array ] args The arguments passed to the method.
122
- #
123
122
  ruby2_keywords def method_missing(name, *args, &block)
124
123
  _target.send(name, *args, &block)
125
124
  end
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Is the document autosaved?
13
13
  # document.autosaved?
14
14
  #
15
- # @return [ true, false ] Has the document already been autosaved?
15
+ # @return [ true | false ] Has the document already been autosaved?
16
16
  def autosaved?
17
17
  Threaded.autosaved?(self)
18
18
  end
@@ -18,7 +18,7 @@ module Mongoid
18
18
  # Association::BelongsTo::Proxy.new(game, person, association)
19
19
  #
20
20
  # @param [ Document ] base The document this association hangs off of.
21
- # @param [ Document, Array<Document> ] target The target (parent) of the
21
+ # @param [ Document | Array<Document> ] target The target (parent) of the
22
22
  # association.
23
23
  # @param [ Association ] association The association object.
24
24
  def initialize(base, target, association)
@@ -34,7 +34,6 @@ module Mongoid
34
34
  #
35
35
  # @example Nullify the association.
36
36
  # person.game.nullify
37
- #
38
37
  def nullify
39
38
  unbind_one
40
39
  _target.save
@@ -46,9 +45,9 @@ module Mongoid
46
45
  # @example Substitute the association.
47
46
  # name.substitute(new_name)
48
47
  #
49
- # @param [ Document, Array<Document> ] replacement The replacement.
48
+ # @param [ Document | Array<Document> ] replacement The replacement.
50
49
  #
51
- # @return [ self, nil ] The association or nil.
50
+ # @return [ self | nil ] The association or nil.
52
51
  def substitute(replacement)
53
52
  unbind_one
54
53
  if replacement
@@ -77,7 +76,7 @@ module Mongoid
77
76
  # @example Normalize the substitute.
78
77
  # proxy.normalize(id)
79
78
  #
80
- # @param [ Document, Object ] replacement The replacement object.
79
+ # @param [ Document | Object ] replacement The replacement object.
81
80
  #
82
81
  # @return [ Document ] The document.
83
82
  def normalize(replacement)
@@ -90,7 +89,7 @@ module Mongoid
90
89
  # @example Can we persist the association?
91
90
  # relation.persistable?
92
91
  #
93
- # @return [ true, false ] If the association is persistable.
92
+ # @return [ true | false ] If the association is persistable.
94
93
  def persistable?
95
94
  _target.persisted? && !_binding? && !_building?
96
95
  end
@@ -97,7 +97,7 @@ module Mongoid
97
97
 
98
98
  # Is this association polymorphic?
99
99
  #
100
- # @return [ true, false ] Whether this association is polymorphic.
100
+ # @return [ true | false ] Whether this association is polymorphic.
101
101
  def polymorphic?
102
102
  @polymorphic ||= !!@options[:polymorphic]
103
103
  end