mongoid 8.0.1 → 8.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) 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/cacheable.rb +2 -2
  47. data/lib/mongoid/changeable.rb +5 -5
  48. data/lib/mongoid/clients/options.rb +1 -1
  49. data/lib/mongoid/clients/validators/storage.rb +3 -3
  50. data/lib/mongoid/config/validators/client.rb +6 -6
  51. data/lib/mongoid/config.rb +7 -7
  52. data/lib/mongoid/contextual/aggregable/memory.rb +1 -1
  53. data/lib/mongoid/contextual/aggregable/mongo.rb +4 -4
  54. data/lib/mongoid/contextual/aggregable/none.rb +1 -1
  55. data/lib/mongoid/contextual/atomic.rb +1 -1
  56. data/lib/mongoid/contextual/geo_near.rb +7 -7
  57. data/lib/mongoid/contextual/memory.rb +5 -5
  58. data/lib/mongoid/contextual/mongo.rb +14 -14
  59. data/lib/mongoid/contextual/none.rb +2 -2
  60. data/lib/mongoid/contextual/queryable.rb +1 -1
  61. data/lib/mongoid/contextual.rb +2 -2
  62. data/lib/mongoid/criteria/findable.rb +7 -4
  63. data/lib/mongoid/criteria/includable.rb +1 -1
  64. data/lib/mongoid/criteria/permission.rb +1 -1
  65. data/lib/mongoid/criteria/queryable/aggregable.rb +2 -2
  66. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  67. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +2 -2
  68. data/lib/mongoid/criteria/queryable/extensions/set.rb +1 -1
  69. data/lib/mongoid/criteria/queryable/extensions/string.rb +3 -3
  70. data/lib/mongoid/criteria/queryable/extensions/symbol.rb +1 -1
  71. data/lib/mongoid/criteria/queryable/key.rb +3 -3
  72. data/lib/mongoid/criteria/queryable/optional.rb +2 -2
  73. data/lib/mongoid/criteria/queryable/options.rb +1 -1
  74. data/lib/mongoid/criteria/queryable/pipeline.rb +1 -1
  75. data/lib/mongoid/criteria/queryable/selectable.rb +3 -3
  76. data/lib/mongoid/criteria/queryable/selector.rb +3 -3
  77. data/lib/mongoid/criteria/queryable/smash.rb +1 -1
  78. data/lib/mongoid/criteria/queryable.rb +1 -1
  79. data/lib/mongoid/criteria/scopable.rb +2 -2
  80. data/lib/mongoid/criteria.rb +14 -9
  81. data/lib/mongoid/deprecable.rb +1 -1
  82. data/lib/mongoid/document.rb +2 -2
  83. data/lib/mongoid/equality.rb +12 -12
  84. data/lib/mongoid/errors/document_not_found.rb +5 -5
  85. data/lib/mongoid/errors/invalid_config_option.rb +1 -1
  86. data/lib/mongoid/errors/invalid_dependent_strategy.rb +1 -1
  87. data/lib/mongoid/errors/invalid_field.rb +1 -1
  88. data/lib/mongoid/errors/invalid_relation.rb +1 -1
  89. data/lib/mongoid/errors/invalid_relation_option.rb +1 -1
  90. data/lib/mongoid/errors/invalid_session_use.rb +1 -1
  91. data/lib/mongoid/errors/invalid_storage_options.rb +1 -1
  92. data/lib/mongoid/errors/mongoid_error.rb +3 -3
  93. data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +1 -1
  94. data/lib/mongoid/errors/no_client_database.rb +1 -1
  95. data/lib/mongoid/errors/no_client_hosts.rb +1 -1
  96. data/lib/mongoid/errors/readonly_attribute.rb +1 -1
  97. data/lib/mongoid/errors/unknown_attribute.rb +1 -1
  98. data/lib/mongoid/extensions/array.rb +1 -1
  99. data/lib/mongoid/extensions/big_decimal.rb +4 -0
  100. data/lib/mongoid/extensions/false_class.rb +1 -1
  101. data/lib/mongoid/extensions/float.rb +6 -2
  102. data/lib/mongoid/extensions/hash.rb +1 -1
  103. data/lib/mongoid/extensions/integer.rb +6 -2
  104. data/lib/mongoid/extensions/module.rb +1 -1
  105. data/lib/mongoid/extensions/object.rb +6 -6
  106. data/lib/mongoid/extensions/string.rb +9 -9
  107. data/lib/mongoid/extensions/symbol.rb +1 -1
  108. data/lib/mongoid/extensions/true_class.rb +1 -1
  109. data/lib/mongoid/fields/foreign_key.rb +4 -4
  110. data/lib/mongoid/fields/localized.rb +9 -4
  111. data/lib/mongoid/fields/standard.rb +7 -7
  112. data/lib/mongoid/fields.rb +9 -9
  113. data/lib/mongoid/findable.rb +7 -6
  114. data/lib/mongoid/indexable/specification.rb +1 -1
  115. data/lib/mongoid/indexable/validators/options.rb +2 -1
  116. data/lib/mongoid/interceptable.rb +4 -4
  117. data/lib/mongoid/matchable.rb +1 -1
  118. data/lib/mongoid/matcher.rb +12 -7
  119. data/lib/mongoid/persistable/creatable.rb +4 -4
  120. data/lib/mongoid/persistable/deletable.rb +1 -1
  121. data/lib/mongoid/persistable/destroyable.rb +1 -1
  122. data/lib/mongoid/persistable/savable.rb +2 -2
  123. data/lib/mongoid/persistable/unsettable.rb +1 -1
  124. data/lib/mongoid/persistable/updatable.rb +7 -7
  125. data/lib/mongoid/persistable/upsertable.rb +1 -1
  126. data/lib/mongoid/persistable.rb +3 -3
  127. data/lib/mongoid/persistence_context.rb +44 -8
  128. data/lib/mongoid/query_cache.rb +2 -2
  129. data/lib/mongoid/scopable.rb +26 -22
  130. data/lib/mongoid/serializable.rb +10 -6
  131. data/lib/mongoid/stateful.rb +10 -10
  132. data/lib/mongoid/tasks/database.rb +0 -2
  133. data/lib/mongoid/threaded/lifecycle.rb +5 -5
  134. data/lib/mongoid/threaded.rb +12 -12
  135. data/lib/mongoid/timestamps/updated.rb +1 -1
  136. data/lib/mongoid/traversable.rb +3 -3
  137. data/lib/mongoid/validatable/localizable.rb +1 -1
  138. data/lib/mongoid/validatable/macros.rb +0 -2
  139. data/lib/mongoid/validatable/presence.rb +2 -2
  140. data/lib/mongoid/validatable/uniqueness.rb +7 -7
  141. data/lib/mongoid/validatable.rb +6 -6
  142. data/lib/mongoid/version.rb +1 -1
  143. data/spec/integration/i18n_fallbacks_spec.rb +1 -17
  144. data/spec/mongoid/cacheable_spec.rb +3 -3
  145. data/spec/mongoid/clients_spec.rb +25 -0
  146. data/spec/mongoid/contextual/memory_spec.rb +4 -5
  147. data/spec/mongoid/contextual/mongo_spec.rb +2 -4
  148. data/spec/mongoid/criteria_projection_spec.rb +0 -1
  149. data/spec/mongoid/criteria_spec.rb +1 -1
  150. data/spec/mongoid/equality_spec.rb +12 -12
  151. data/spec/mongoid/extensions/big_decimal_spec.rb +15 -0
  152. data/spec/mongoid/extensions/float_spec.rb +10 -3
  153. data/spec/mongoid/extensions/integer_spec.rb +10 -3
  154. data/spec/mongoid/fields/localized_spec.rb +37 -12
  155. data/spec/mongoid/indexable_spec.rb +23 -1
  156. data/spec/mongoid/scopable_spec.rb +34 -16
  157. data/spec/mongoid/validatable/uniqueness_spec.rb +0 -1
  158. data/spec/support/macros.rb +16 -0
  159. data.tar.gz.sig +0 -0
  160. metadata +643 -643
  161. metadata.gz.sig +0 -0
@@ -54,7 +54,7 @@ module Mongoid
54
54
  # @api private
55
55
  #
56
56
  # @param [ Object ] criteria
57
- # @return [ Boolean ] if should permit
57
+ # @return [ true | false ] if should permit
58
58
  def should_permit?(criteria)
59
59
  if criteria.respond_to?(:permitted?)
60
60
  return criteria.permitted?
@@ -20,7 +20,7 @@ module Mongoid
20
20
  # @example Is the aggregable aggregating?
21
21
  # aggregable.aggregating?
22
22
  #
23
- # @return [ true, false ] If the aggregable is aggregating.
23
+ # @return [ true | false ] If the aggregable is aggregating.
24
24
  def aggregating?
25
25
  !!@aggregating
26
26
  end
@@ -69,7 +69,7 @@ module Mongoid
69
69
  # @example Add an unwind to the pipeline.
70
70
  # aggregable.unwind(:field)
71
71
  #
72
- # @param [ String, Symbol ] field The name of the field to unwind.
72
+ # @param [ String | Symbol ] field The name of the field to unwind.
73
73
  #
74
74
  # @return [ Aggregable ] The aggregable.
75
75
  def unwind(field)
@@ -17,7 +17,7 @@ module Mongoid
17
17
  #
18
18
  # @param [ Object ] object The object to evolve.
19
19
  #
20
- # @return [ true, false ] The boolean value.
20
+ # @return [ true | false ] The boolean value.
21
21
  def evolve(object)
22
22
  __evolve__(object) do |obj|
23
23
  mongoize(obj)
@@ -23,7 +23,7 @@ module Mongoid
23
23
  # @example Evolve the object to a regex.
24
24
  # Regexp.evolve("\A[123]")
25
25
  #
26
- # @param [ Regexp, String ] object The object to evolve.
26
+ # @param [ Regexp | String ] object The object to evolve.
27
27
  #
28
28
  # @return [ Regexp ] The evolved regex.
29
29
  def evolve(object)
@@ -50,7 +50,7 @@ module Mongoid
50
50
  # @example Evolve the object to a regex.
51
51
  # BSON::Regexp::Raw.evolve("\\A[123]")
52
52
  #
53
- # @param [ BSON::Regexp::Raw, String ] object The object to evolve.
53
+ # @param [ BSON::Regexp::Raw | String ] object The object to evolve.
54
54
  #
55
55
  # @return [ BSON::Regexp::Raw ] The evolved raw regex.
56
56
  def evolve(object)
@@ -16,7 +16,7 @@ module Mongoid
16
16
  # @example Evolve the set.
17
17
  # Set.evolve(set)
18
18
  #
19
- # @param [ Set, Object ] object The object to evolve.
19
+ # @param [ Set | Object ] object The object to evolve.
20
20
  #
21
21
  # @return [ Array ] The evolved set.
22
22
  def evolve(object)
@@ -60,7 +60,7 @@ module Mongoid
60
60
  # "field".__expr_part__(value)
61
61
  #
62
62
  # @param [ Object ] value The value of the criteria.
63
- # @param [ true, false ] negating If the selection should be negated.
63
+ # @param [ true | false ] negating If the selection should be negated.
64
64
  #
65
65
  # @return [ Hash ] The selection.
66
66
  def __expr_part__(value, negating = false)
@@ -84,9 +84,9 @@ module Mongoid
84
84
  # @example Get the value as an expression.
85
85
  # String.__expr_part__("field", value)
86
86
  #
87
- # @param [ String, Symbol ] key The field key.
87
+ # @param [ String | Symbol ] key The field key.
88
88
  # @param [ Object ] value The value of the criteria.
89
- # @param [ true, false ] negating If the selection should be negated.
89
+ # @param [ true | false ] negating If the selection should be negated.
90
90
  #
91
91
  # @return [ Hash ] The selection.
92
92
  def __expr_part__(key, value, negating = false)
@@ -14,7 +14,7 @@ module Mongoid
14
14
  # :field.__expr_part__(value)
15
15
  #
16
16
  # @param [ Object ] value The value of the criteria.
17
- # @param [ true, false ] negating If the selection should be negated.
17
+ # @param [ true | false ] negating If the selection should be negated.
18
18
  #
19
19
  # @return [ Hash ] The selection.
20
20
  def __expr_part__(value, negating = false)
@@ -82,7 +82,7 @@ module Mongoid
82
82
  #
83
83
  # @param [ Object ] other The object to compare to.
84
84
  #
85
- # @return [ true, false ] If the objects are equal.
85
+ # @return [ true | false ] If the objects are equal.
86
86
  def ==(other)
87
87
  return false unless other.is_a?(Key)
88
88
  name == other.name && operator == other.operator && expanded == other.expanded
@@ -104,7 +104,7 @@ module Mongoid
104
104
  # @example Instantiate a key for sorting.
105
105
  # Key.new(:field, :__override__, 1)
106
106
  #
107
- # @param [ String, Symbol ] name The field name.
107
+ # @param [ String | Symbol ] name The field name.
108
108
  # @param [ Symbol ] strategy The name of the merge strategy.
109
109
  # @param [ String | Integer ] operator The MongoDB operator,
110
110
  # or sort direction (1 or -1).
@@ -124,7 +124,7 @@ module Mongoid
124
124
  # key.__expr_part__(50)
125
125
  #
126
126
  # @param [ Object ] object The value to be included.
127
- # @param [ true, false ] negating If the selection should be negated.
127
+ # @param [ true | false ] negating If the selection should be negated.
128
128
  #
129
129
  # @return [ Hash ] The raw MongoDB selector.
130
130
  def __expr_part__(object, negating = false)
@@ -163,7 +163,7 @@ module Mongoid
163
163
  # @example Add sorting options via a string.
164
164
  # optional.order_by("name ASC, dob DESC")
165
165
  #
166
- # @param [ Array, Hash, String ] spec The sorting specification.
166
+ # @param [ Array | Hash | String ] spec The sorting specification.
167
167
  #
168
168
  # @return [ Optional ] The cloned optional.
169
169
  def order_by(*spec)
@@ -184,7 +184,7 @@ module Mongoid
184
184
  # @example Replace the ordering.
185
185
  # optional.reorder(name: :asc)
186
186
  #
187
- # @param [ Array, Hash, String ] spec The sorting specification.
187
+ # @param [ Array | Hash | String ] spec The sorting specification.
188
188
  #
189
189
  # @return [ Optional ] The cloned optional.
190
190
  def reorder(*spec)
@@ -54,7 +54,7 @@ module Mongoid
54
54
  # @example Store a value in the options.
55
55
  # options.store(:key, "testing")
56
56
  #
57
- # @param [ String, Symbol ] key The name of the attribute.
57
+ # @param [ String | Symbol ] key The name of the attribute.
58
58
  # @param [ Object ] value The value to add.
59
59
  #
60
60
  # @return [ Object ] The stored object.
@@ -67,7 +67,7 @@ module Mongoid
67
67
  # pipeline.unwind(:field)
68
68
  # pipeline.unwind(document)
69
69
  #
70
- # @param [ String, Symbol, Hash ] field_or_doc A field name or a
70
+ # @param [ String | Symbol | Hash ] field_or_doc A field name or a
71
71
  # document.
72
72
  #
73
73
  # @return [ Pipeline ] The pipeline.
@@ -529,7 +529,7 @@ module Mongoid
529
529
  # @example Is the selectable negating?
530
530
  # selectable.negating?
531
531
  #
532
- # @return [ true, false ] If the selectable is negating.
532
+ # @return [ true | false ] If the selectable is negating.
533
533
  def negating?
534
534
  !!negating
535
535
  end
@@ -736,7 +736,7 @@ module Mongoid
736
736
  # conditions in a query. Mongoid will build such a query but the
737
737
  # server will return an error when trying to execute it.
738
738
  #
739
- # @param [ String, Symbol ] terms A string of terms that MongoDB parses
739
+ # @param [ String | Symbol ] terms A string of terms that MongoDB parses
740
740
  # and uses to query the text index.
741
741
  # @param [ Hash ] opts Text search options. See MongoDB documentation
742
742
  # for options.
@@ -774,7 +774,7 @@ module Mongoid
774
774
  # @example Add a javascript selection.
775
775
  # selectable.where("this.name == 'syd'")
776
776
  #
777
- # @param [ String, Hash ] criterion The javascript or standard selection.
777
+ # @param [ String | Hash ] criterion The javascript or standard selection.
778
778
  #
779
779
  # @return [ Selectable ] The cloned selectable.
780
780
  def where(*criteria)
@@ -13,7 +13,7 @@ module Mongoid
13
13
  # @example Merge in another selector.
14
14
  # selector.merge!(name: "test")
15
15
  #
16
- # @param [ Hash, Selector ] other The object to merge in.
16
+ # @param [ Hash | Selector ] other The object to merge in.
17
17
  #
18
18
  # @return [ Selector ] The selector.
19
19
  def merge!(other)
@@ -43,7 +43,7 @@ module Mongoid
43
43
  # @example Store a value in the selector.
44
44
  # selector.store(:key, "testing")
45
45
  #
46
- # @param [ String, Symbol ] key The name of the attribute.
46
+ # @param [ String | Symbol ] key The name of the attribute.
47
47
  # @param [ Object ] value The value to add.
48
48
  #
49
49
  # @return [ Object ] The stored object.
@@ -277,7 +277,7 @@ module Mongoid
277
277
  #
278
278
  # @param [ String ] key The key to check.
279
279
  #
280
- # @return [ true, false ] If the key is for a multi-select.
280
+ # @return [ true | false ] If the key is for a multi-select.
281
281
  def multi_selection?(key)
282
282
  %w($and $or $nor).include?(key)
283
283
  end
@@ -95,7 +95,7 @@ module Mongoid
95
95
  # @example Get the name and serializer.
96
96
  # smash.storage_pair("id")
97
97
  #
98
- # @param [ Symbol, String ] key The key provided to the selection.
98
+ # @param [ Symbol | String ] key The key provided to the selection.
99
99
  #
100
100
  # @return [ Array<String, Object> ] The name of the db field and
101
101
  # serializer.
@@ -46,7 +46,7 @@ module Mongoid
46
46
  #
47
47
  # @param [ Object ] other The object to compare against.
48
48
  #
49
- # @return [ true, false ] If the objects are equal.
49
+ # @return [ true | false ] If the objects are equal.
50
50
  def ==(other)
51
51
  return false unless other.is_a?(Queryable)
52
52
  selector == other.selector && options == other.options
@@ -83,7 +83,7 @@ module Mongoid
83
83
  # @example Is the default scope applied?
84
84
  # criteria.scoped?
85
85
  #
86
- # @return [ true, false ] If the default scope is applied.
86
+ # @return [ true | false ] If the default scope is applied.
87
87
  def scoped?
88
88
  !!(defined?(@scoped) ? @scoped : nil)
89
89
  end
@@ -108,7 +108,7 @@ module Mongoid
108
108
  # @example Is the criteria unscoped?
109
109
  # criteria.unscoped?
110
110
  #
111
- # @return [ true, false ] If the criteria is force unscoped.
111
+ # @return [ true | false ] If the criteria is force unscoped.
112
112
  def unscoped?
113
113
  !!(defined?(@unscoped) ? @unscoped : nil)
114
114
  end
@@ -52,7 +52,7 @@ module Mongoid
52
52
  #
53
53
  # @param [ Object ] other The other +Enumerable+ or +Criteria+ to compare to.
54
54
  #
55
- # @return [ true, false ] If the objects are equal.
55
+ # @return [ true | false ] If the objects are equal.
56
56
  def ==(other)
57
57
  return super if other.respond_to?(:selector)
58
58
  entries == other
@@ -73,6 +73,9 @@ module Mongoid
73
73
  # treated by Mongoid - the decision between delegating to +Findable+ vs
74
74
  # +Enumerable+ is made solely based on whether +find+ is passed a block.
75
75
  #
76
+ # @note Each argument can be an individual id, an array of ids or
77
+ # a nested array. Each array will be flattened.
78
+ #
76
79
  # @example Finds a document by its _id, invokes Findable#find.
77
80
  # critera.find("1234")
78
81
  #
@@ -85,6 +88,9 @@ module Mongoid
85
88
  # @example Tries to find a document whose _id is the stringification of the provided Proc, typically failing.
86
89
  # enumerator = criteria.find(-> { "Default Band" })
87
90
  #
91
+ # @param [ Object | Array<Object> ] *args The ids.
92
+ # @param [ Proc ] block Optional block to pass.
93
+ #
88
94
  # @return [ Document | Array<Document> | nil ] A document or matching documents.
89
95
  #
90
96
  # @raise Errors::DocumentNotFound If the parameters were _id values and
@@ -138,7 +144,7 @@ module Mongoid
138
144
  # @example Is the criteria for embedded documents?
139
145
  # criteria.embedded?
140
146
  #
141
- # @return [ true, false ] If the criteria is embedded.
147
+ # @return [ true | false ] If the criteria is embedded.
142
148
  def embedded?
143
149
  !!@embedded
144
150
  end
@@ -268,7 +274,7 @@ module Mongoid
268
274
  # @example Is the criteria a none criteria?
269
275
  # criteria.empty_and_chainable?
270
276
  #
271
- # @return [ true, false ] If the criteria is a none.
277
+ # @return [ true | false ] If the criteria is a none.
272
278
  def empty_and_chainable?
273
279
  !!@none
274
280
  end
@@ -326,9 +332,9 @@ module Mongoid
326
332
  # crtiteria.respond_to?(:each)
327
333
  #
328
334
  # @param [ Symbol ] name The name of the class method on the +Document+.
329
- # @param [ true, false ] include_private Whether to include privates.
335
+ # @param [ true | false ] include_private Whether to include privates.
330
336
  #
331
- # @return [ true, false ] If the criteria responds to the method.
337
+ # @return [ true | false ] If the criteria responds to the method.
332
338
  def respond_to?(name, include_private = false)
333
339
  super || klass.respond_to?(name) || CHECK.respond_to?(name, include_private)
334
340
  end
@@ -379,7 +385,7 @@ module Mongoid
379
385
  # @example Add a javascript selection.
380
386
  # criteria.where("this.name == 'syd'")
381
387
  #
382
- # @param [ String, Hash ] expression The javascript or standard selection.
388
+ # @param [ String | Hash ] expression The javascript or standard selection.
383
389
  #
384
390
  # @raise [ UnsupportedJavascript ] If provided a string and the criteria
385
391
  # is embedded.
@@ -405,7 +411,6 @@ module Mongoid
405
411
  super
406
412
  end
407
413
 
408
-
409
414
  # Get a version of this criteria without the options.
410
415
  #
411
416
  # @example Get the criteria without options.
@@ -511,7 +516,7 @@ module Mongoid
511
516
  # @example Add the type selection.
512
517
  # criteria.merge_type_selection
513
518
  #
514
- # @return [ true, false ] If type selection was added.
519
+ # @return [ true | false ] If type selection was added.
515
520
  def merge_type_selection
516
521
  selector.merge!(type_selection) if type_selectable?
517
522
  end
@@ -523,7 +528,7 @@ module Mongoid
523
528
  # @example If the criteria type selectable?
524
529
  # criteria.type_selectable?
525
530
  #
526
- # @return [ true, false ] If type selection should be added.
531
+ # @return [ true | false ] If type selection should be added.
527
532
  def type_selectable?
528
533
  klass.hereditary? &&
529
534
  !selector.keys.include?(self.discriminator_key) &&
@@ -24,7 +24,7 @@ module Mongoid
24
24
  # #=> Mongoid.logger.warn("meow is deprecated and will be removed from Mongoid 8.0 (eat :catnip instead)")
25
25
  #
26
26
  # @param [ Module ] target_module The parent which contains the method.
27
- # @param [ Symbol | Hash<Symbol, [Symbol|String]> ] method_descriptors
27
+ # @param [ Symbol | Hash<Symbol, [ Symbol | String ]> ] method_descriptors
28
28
  # The methods to deprecate, with optional replacement instructions.
29
29
  def deprecate(target_module, *method_descriptors)
30
30
  Mongoid::Deprecation.deprecate_methods(target_module, *method_descriptors)
@@ -56,7 +56,7 @@ module Mongoid
56
56
  # @example Check if frozen
57
57
  # document.frozen?
58
58
  #
59
- # @return [ true, false ] True if frozen, else false.
59
+ # @return [ true | false ] True if frozen, else false.
60
60
  def frozen?
61
61
  attributes.frozen?
62
62
  end
@@ -150,7 +150,7 @@ module Mongoid
150
150
  #
151
151
  # @param [ Hash ] options The options.
152
152
  #
153
- # @option options [ true, false ] :compact (Deprecated) Whether to include fields
153
+ # @option options [ true | false ] :compact (Deprecated) Whether to include fields
154
154
  # with nil values in the json document.
155
155
  #
156
156
  # @return [ Hash ] The document as json.
@@ -26,9 +26,9 @@ module Mongoid
26
26
  # @example Compare for equality.
27
27
  # document == other
28
28
  #
29
- # @param [ Document, Object ] other The other object to compare with.
29
+ # @param [ Document | Object ] other The other object to compare with.
30
30
  #
31
- # @return [ true, false ] True if the ids are equal, false if not.
31
+ # @return [ true | false ] True if the ids are equal, false if not.
32
32
  def ==(other)
33
33
  self.class == other.class &&
34
34
  attributes["_id"] == other.attributes["_id"]
@@ -39,14 +39,14 @@ module Mongoid
39
39
  # @example Compare the classes.
40
40
  # document === other
41
41
  #
42
- # @param [ Document, Object ] other The other object to compare with.
42
+ # @param [ Document | Object ] other The other object to compare with.
43
43
  #
44
- # @return [ true, false ] True if the classes are equal, false if not.
44
+ # @return [ true | false ] True if the classes are equal, false if not.
45
45
  def ===(other)
46
46
  if Mongoid.legacy_triple_equals
47
- super
48
- else
49
47
  other.class == Class ? self.class === other : self == other
48
+ else
49
+ super
50
50
  end
51
51
  end
52
52
 
@@ -55,9 +55,9 @@ module Mongoid
55
55
  # @example Perform equality checking.
56
56
  # document.eql?(other)
57
57
  #
58
- # @param [ Document, Object ] other The object to check against.
58
+ # @param [ Document | Object ] other The object to check against.
59
59
  #
60
- # @return [ true, false ] True if equal, false if not.
60
+ # @return [ true | false ] True if equal, false if not.
61
61
  def eql?(other)
62
62
  self == (other)
63
63
  end
@@ -68,14 +68,14 @@ module Mongoid
68
68
  # @example Compare the classes.
69
69
  # document === other
70
70
  #
71
- # @param [ Document, Object ] other The other object to compare with.
71
+ # @param [ Document | Object ] other The other object to compare with.
72
72
  #
73
- # @return [ true, false ] True if the classes are equal, false if not.
73
+ # @return [ true | false ] True if the classes are equal, false if not.
74
74
  def ===(other)
75
75
  if Mongoid.legacy_triple_equals
76
- other.is_a?(self)
77
- else
78
76
  other.class == Class ? self <= other : other.is_a?(self)
77
+ else
78
+ other.is_a?(self)
79
79
  end
80
80
  end
81
81
  end
@@ -19,8 +19,8 @@ module Mongoid
19
19
  # DocumentNotFound.new(Person, :ssn => "1234", :name => "Helen")
20
20
  #
21
21
  # @param [ Class ] klass The model class.
22
- # @param [ Hash, Array, Object ] params The attributes or ids.
23
- # @param [ Array, Hash ] unmatched The unmatched ids, if appropriate. If
22
+ # @param [ Hash | Array | Object ] params The attributes or ids.
23
+ # @param [ Array | Hash ] unmatched The unmatched ids, if appropriate. If
24
24
  # there is a shard key this will be a hash.
25
25
  def initialize(klass, params, unmatched = nil)
26
26
  if !unmatched && !params.is_a?(Hash)
@@ -50,7 +50,7 @@ module Mongoid
50
50
  # @example Get the missing string.
51
51
  # error.missing(1)
52
52
  #
53
- # @param [ Object, Array ] unmatched The ids that did not match.
53
+ # @param [ Object | Array ] unmatched The ids that did not match.
54
54
  #
55
55
  # @return [ String ] The missing string.
56
56
  def missing(unmatched)
@@ -68,7 +68,7 @@ module Mongoid
68
68
  # @example Get the searched string.
69
69
  # error.searched(1)
70
70
  #
71
- # @param [ Object, Array ] params The ids that were searched for.
71
+ # @param [ Object | Array ] params The ids that were searched for.
72
72
  #
73
73
  # @return [ String ] The searched string.
74
74
  def searched(params)
@@ -84,7 +84,7 @@ module Mongoid
84
84
  # @example Get the total.
85
85
  # error.total([ 1, 2, 3 ])
86
86
  #
87
- # @param [ Object, Array ] params What was searched for.
87
+ # @param [ Object | Array ] params What was searched for.
88
88
  #
89
89
  # @return [ Integer ] The total number.
90
90
  def total(params)
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Create the new error.
13
13
  # InvalidConfigOption.new(:name, [ :option ])
14
14
  #
15
- # @param [ Symbol, String ] name The attempted config option name.
15
+ # @param [ Symbol | String ] name The attempted config option name.
16
16
  def initialize(name)
17
17
  super(
18
18
  compose_message(
@@ -13,7 +13,7 @@ module Mongoid
13
13
  #
14
14
  # @param [ Mongoid::Association ] association The association for which this
15
15
  # dependency is defined.
16
- # @param [ Symbol, String ] invalid_strategy The attempted invalid strategy.
16
+ # @param [ Symbol | String ] invalid_strategy The attempted invalid strategy.
17
17
  # @param [ Array<Symbol> ] valid_strategies The valid strategies.
18
18
  def initialize(association, invalid_strategy, valid_strategies)
19
19
  super(
@@ -42,7 +42,7 @@ module Mongoid
42
42
  # @param [ Class ] klass The document class.
43
43
  # @param [ Symbol ] name The method name.
44
44
  #
45
- # @return [ Class, Module ] The originating class or module.
45
+ # @return [ Class | Module ] The originating class or module.
46
46
  def origin(klass, name)
47
47
  klass.instance_method(name).owner
48
48
  end
@@ -38,7 +38,7 @@ module Mongoid
38
38
  # @param [ Class ] klass The document class.
39
39
  # @param [ Symbol ] name The method name.
40
40
  #
41
- # @return [ Class, Module ] The originating class or module.
41
+ # @return [ Class | Module ] The originating class or module.
42
42
  def origin(klass, name)
43
43
  klass.instance_method(name).owner
44
44
  end
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # InvalidRelationOption.new(Person, invalid_option: 'make_me_a_sandwich')
13
13
  #
14
14
  # @param [ Class ] klass The model class.
15
- # @param [ String, Symbol ] name The association name.
15
+ # @param [ String | Symbol ] name The association name.
16
16
  # @param [ Symbol ] option The invalid option.
17
17
  # @param [ Array<Symbol> ] valid_options The valid option.
18
18
  def initialize(klass, name, option, valid_options)
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Create the error.
13
13
  # InvalidSessionUse.new(:invalid_session_use)
14
14
  #
15
- # @param [ :invalid_session_use, :invalid_session_nesting ] error_type The type of session misuse.
15
+ # @param [ :invalid_session_use | :invalid_session_nesting ] error_type The type of session misuse.
16
16
  def initialize(error_type)
17
17
  super(compose_message(error_type.to_s))
18
18
  end
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # InvalidStorageOptions.new(Person, invalid_option: 'name')
13
13
  #
14
14
  # @param [ Class ] klass The model class.
15
- # @param [ Hash, String, Symbol ] options The provided options.
15
+ # @param [ Hash | String | Symbol ] options The provided options.
16
16
  def initialize(klass, options)
17
17
  super(
18
18
  compose_message(
@@ -53,7 +53,7 @@ module Mongoid
53
53
  # @example Create the problem.
54
54
  # error.problem("error", {})
55
55
  #
56
- # @param [ String, Symbol ] key The error key.
56
+ # @param [ String | Symbol ] key The error key.
57
57
  # @param [ Hash ] attributes The attributes to interpolate.
58
58
  #
59
59
  # @return [ String ] The problem.
@@ -66,7 +66,7 @@ module Mongoid
66
66
  # @example Create the summary.
67
67
  # error.summary("error", {})
68
68
  #
69
- # @param [ String, Symbol ] key The error key.
69
+ # @param [ String | Symbol ] key The error key.
70
70
  # @param [ Hash ] attributes The attributes to interpolate.
71
71
  #
72
72
  # @return [ String ] The summary.
@@ -79,7 +79,7 @@ module Mongoid
79
79
  # @example Create the resolution.
80
80
  # error.resolution("error", {})
81
81
  #
82
- # @param [ String, Symbol ] key The error key.
82
+ # @param [ String | Symbol ] key The error key.
83
83
  # @param [ Hash ] attributes The attributes to interpolate.
84
84
  #
85
85
  # @return [ String ] The resolution.
@@ -13,7 +13,7 @@ module Mongoid
13
13
  # NestedAttributesMetadataNotFound.new(klass, name)
14
14
  #
15
15
  # @param [ Class ] klass The class of the document.
16
- # @param [ Symbol, String ] name The name of the association
16
+ # @param [ Symbol | String ] name The name of the association
17
17
  def initialize(klass, name)
18
18
  super(
19
19
  compose_message(
@@ -11,7 +11,7 @@ module Mongoid
11
11
  # @example Create the new error.
12
12
  # NoClientDatabase.new(:default, {}})
13
13
  #
14
- # @param [ Symbol, String ] name The db config key.
14
+ # @param [ Symbol | String ] name The db config key.
15
15
  # @param [ Hash ] config The hash configuration options.
16
16
  def initialize(name, config)
17
17
  super(
@@ -11,7 +11,7 @@ module Mongoid
11
11
  # @example Create the new error.
12
12
  # NoClientHosts.new(:default, {}})
13
13
  #
14
- # @param [ Symbol, String ] name The db config key.
14
+ # @param [ Symbol | String ] name The db config key.
15
15
  # @param [ Hash ] config The hash configuration options.
16
16
  def initialize(name, config)
17
17
  super(
@@ -12,7 +12,7 @@ module Mongoid
12
12
  # @example Create the new error.
13
13
  # ReadonlyAttribute.new(:title, "mr")
14
14
  #
15
- # @param [ Symbol, String ] name The name of the attribute.
15
+ # @param [ Symbol | String ] name The name of the attribute.
16
16
  # @param [ Object ] value The attempted set value.
17
17
  def initialize(name, value)
18
18
  super(
@@ -13,7 +13,7 @@ module Mongoid
13
13
  # UnknownAttribute.new(Person, "gender")
14
14
  #
15
15
  # @param [ Class ] klass The model class.
16
- # @param [ String, Symbol ] name The name of the attribute.
16
+ # @param [ String | Symbol ] name The name of the attribute.
17
17
  def initialize(klass, name)
18
18
  super(
19
19
  compose_message("unknown_attribute", { klass: klass.name, name: name })
@@ -76,7 +76,7 @@ module Mongoid
76
76
  # @example Is this multi args?
77
77
  # [ 1, 2, 3 ].multi_arged?
78
78
  #
79
- # @return [ true, false ] If the array is multi args.
79
+ # @return [ true | false ] If the array is multi args.
80
80
  def multi_arged?
81
81
  !first.is_a?(Hash) && first.resizable? || size > 1
82
82
  end