mongoid 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mongoid/atomic.rb +3 -3
  3. data/lib/mongoid/attributes.rb +1 -2
  4. data/lib/mongoid/attributes/dynamic.rb +3 -2
  5. data/lib/mongoid/attributes/nested.rb +1 -1
  6. data/lib/mongoid/attributes/processing.rb +0 -4
  7. data/lib/mongoid/changeable.rb +1 -1
  8. data/lib/mongoid/clients/options.rb +1 -1
  9. data/lib/mongoid/composable.rb +3 -1
  10. data/lib/mongoid/contextual/atomic.rb +1 -1
  11. data/lib/mongoid/contextual/geo_near.rb +3 -2
  12. data/lib/mongoid/contextual/memory.rb +3 -3
  13. data/lib/mongoid/contextual/mongo.rb +5 -5
  14. data/lib/mongoid/contextual/none.rb +14 -2
  15. data/lib/mongoid/copyable.rb +1 -5
  16. data/lib/mongoid/criteria.rb +2 -2
  17. data/lib/mongoid/criteria/findable.rb +3 -2
  18. data/lib/mongoid/criteria/includable.rb +2 -2
  19. data/lib/mongoid/criteria/queryable/aggregable.rb +1 -1
  20. data/lib/mongoid/criteria/queryable/extensions/array.rb +1 -1
  21. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  22. data/lib/mongoid/criteria/queryable/extensions/hash.rb +4 -4
  23. data/lib/mongoid/criteria/queryable/extensions/object.rb +4 -4
  24. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +34 -0
  25. data/lib/mongoid/criteria/queryable/options.rb +16 -0
  26. data/lib/mongoid/criteria/queryable/selector.rb +1 -1
  27. data/lib/mongoid/document.rb +1 -1
  28. data/lib/mongoid/errors/delete_restriction.rb +2 -2
  29. data/lib/mongoid/errors/inverse_not_found.rb +1 -1
  30. data/lib/mongoid/extensions/hash.rb +3 -2
  31. data/lib/mongoid/extensions/object.rb +2 -2
  32. data/lib/mongoid/extensions/time.rb +1 -1
  33. data/lib/mongoid/factory.rb +0 -1
  34. data/lib/mongoid/fields/foreign_key.rb +2 -2
  35. data/lib/mongoid/findable.rb +1 -1
  36. data/lib/mongoid/indexable.rb +3 -2
  37. data/lib/mongoid/indexable/specification.rb +1 -1
  38. data/lib/mongoid/interceptable.rb +3 -9
  39. data/lib/mongoid/loggable.rb +1 -1
  40. data/lib/mongoid/matchable.rb +16 -9
  41. data/lib/mongoid/matchable/all.rb +2 -2
  42. data/lib/mongoid/matchable/and.rb +3 -3
  43. data/lib/mongoid/matchable/default.rb +2 -2
  44. data/lib/mongoid/matchable/elem_match.rb +3 -3
  45. data/lib/mongoid/matchable/exists.rb +2 -2
  46. data/lib/mongoid/matchable/gt.rb +2 -2
  47. data/lib/mongoid/matchable/gte.rb +2 -2
  48. data/lib/mongoid/matchable/in.rb +2 -2
  49. data/lib/mongoid/matchable/lt.rb +2 -2
  50. data/lib/mongoid/matchable/lte.rb +2 -2
  51. data/lib/mongoid/matchable/ne.rb +2 -2
  52. data/lib/mongoid/matchable/nin.rb +2 -2
  53. data/lib/mongoid/matchable/or.rb +3 -3
  54. data/lib/mongoid/matchable/regexp.rb +27 -0
  55. data/lib/mongoid/matchable/size.rb +2 -2
  56. data/lib/mongoid/persistable.rb +0 -3
  57. data/lib/mongoid/persistable/creatable.rb +2 -4
  58. data/lib/mongoid/persistable/deletable.rb +1 -1
  59. data/lib/mongoid/persistable/settable.rb +1 -1
  60. data/lib/mongoid/persistable/upsertable.rb +1 -1
  61. data/lib/mongoid/persistence_context.rb +2 -3
  62. data/lib/mongoid/relations/accessors.rb +1 -2
  63. data/lib/mongoid/relations/bindings/embedded/in.rb +0 -4
  64. data/lib/mongoid/relations/bindings/embedded/many.rb +1 -8
  65. data/lib/mongoid/relations/bindings/embedded/one.rb +0 -10
  66. data/lib/mongoid/relations/bindings/referenced/many.rb +0 -4
  67. data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +4 -4
  68. data/lib/mongoid/relations/builders/embedded/one.rb +1 -1
  69. data/lib/mongoid/relations/builders/nested_attributes/many.rb +1 -1
  70. data/lib/mongoid/relations/conversions.rb +1 -1
  71. data/lib/mongoid/relations/counter_cache.rb +10 -10
  72. data/lib/mongoid/relations/eager.rb +6 -11
  73. data/lib/mongoid/relations/eager/base.rb +4 -4
  74. data/lib/mongoid/relations/embedded/batchable.rb +3 -3
  75. data/lib/mongoid/relations/embedded/in.rb +1 -3
  76. data/lib/mongoid/relations/embedded/many.rb +12 -9
  77. data/lib/mongoid/relations/embedded/one.rb +1 -3
  78. data/lib/mongoid/relations/macros.rb +3 -2
  79. data/lib/mongoid/relations/metadata.rb +3 -3
  80. data/lib/mongoid/relations/nested_builder.rb +1 -1
  81. data/lib/mongoid/relations/proxy.rb +3 -2
  82. data/lib/mongoid/relations/referenced/in.rb +1 -4
  83. data/lib/mongoid/relations/referenced/many.rb +5 -7
  84. data/lib/mongoid/relations/referenced/many_to_many.rb +2 -2
  85. data/lib/mongoid/relations/referenced/one.rb +0 -2
  86. data/lib/mongoid/relations/reflections.rb +2 -2
  87. data/lib/mongoid/relations/synchronization.rb +11 -11
  88. data/lib/mongoid/scopable.rb +2 -2
  89. data/lib/mongoid/serializable.rb +4 -3
  90. data/lib/mongoid/tasks/database.rb +2 -1
  91. data/lib/mongoid/threaded.rb +4 -4
  92. data/lib/mongoid/validatable.rb +1 -1
  93. data/lib/mongoid/validatable/macros.rb +4 -2
  94. data/lib/mongoid/version.rb +1 -1
  95. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +12 -2
  96. data/spec/app/models/book.rb +2 -1
  97. data/spec/app/models/page.rb +1 -1
  98. data/spec/mongoid/contextual/none_spec.rb +15 -0
  99. data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +89 -0
  100. data/spec/mongoid/criteria/queryable/selectable_spec.rb +15 -0
  101. data/spec/mongoid/criteria_spec.rb +6 -2
  102. data/spec/mongoid/interceptable_spec.rb +19 -0
  103. data/spec/mongoid/matchable/all_spec.rb +4 -4
  104. data/spec/mongoid/matchable/and_spec.rb +10 -10
  105. data/spec/mongoid/matchable/default_spec.rb +12 -12
  106. data/spec/mongoid/matchable/elem_match_spec.rb +11 -11
  107. data/spec/mongoid/matchable/exists_spec.rb +5 -5
  108. data/spec/mongoid/matchable/gt_spec.rb +8 -8
  109. data/spec/mongoid/matchable/gte_spec.rb +8 -8
  110. data/spec/mongoid/matchable/in_spec.rb +5 -5
  111. data/spec/mongoid/matchable/lt_spec.rb +8 -8
  112. data/spec/mongoid/matchable/lte_spec.rb +8 -8
  113. data/spec/mongoid/matchable/ne_spec.rb +5 -5
  114. data/spec/mongoid/matchable/nin_spec.rb +5 -5
  115. data/spec/mongoid/matchable/or_spec.rb +7 -7
  116. data/spec/mongoid/matchable/regexp_spec.rb +59 -0
  117. data/spec/mongoid/matchable/size_spec.rb +3 -3
  118. data/spec/mongoid/matchable_spec.rb +108 -58
  119. data/spec/mongoid/persistable/deletable_spec.rb +15 -0
  120. data/spec/mongoid/persistable/settable_spec.rb +16 -0
  121. data/spec/mongoid/persistence_context_spec.rb +22 -1
  122. data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +4 -4
  123. data/spec/mongoid/relations/embedded/many_spec.rb +24 -6
  124. data/spec/mongoid/relations/referenced/many_to_many_spec.rb +1 -1
  125. data/spec/mongoid/relations/synchronization_spec.rb +48 -2
  126. data/spec/mongoid/relations/touchable_spec.rb +40 -0
  127. data/spec/mongoid/validatable/uniqueness_spec.rb +2 -0
  128. data/spec/spec_helper.rb +1 -1
  129. metadata +9 -26
  130. checksums.yaml.gz.sig +0 -0
  131. data.tar.gz.sig +0 -1
  132. metadata.gz.sig +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57e0133222699f9072fe67b609e7212327028ff
4
- data.tar.gz: f2f799925ab8ca3b9126b16fe5a8d52c03fb1146
3
+ metadata.gz: 8df15f3d764e3c19bcc5719c656f833ce258bb65
4
+ data.tar.gz: 335173b371125d1e84100af19293bccf459df5b8
5
5
  SHA512:
6
- metadata.gz: 8139bde85b47d8920a022f4f1a3c68796c446192128be7a7ceb59607c82be58404a956e89676e61ce61a6f39fd691b4b8f39bf2a31663ef64f482a5271986484
7
- data.tar.gz: d500146fa38cbdf1e5d915fa164ef465f4b0ba3ffc7568d77fc85bc9576b61dab8efdbffa42ff8fb2b72063997b8207c264ec52a2f11c04140f09c2a5532b778
6
+ metadata.gz: e6fabe8ac17c05be402c8dd42bff52a4158e0a0d0650cd36363a7439ea19e32d0a3b28427b85fb88749df2941d2ba5fa4c639aa74f9b70ef0e4875acd4438ae6
7
+ data.tar.gz: 40cf34caa79067109baeee5b434f8e2497c654a91248a73a220ac1ded8d685fbc3ea13adaa0e4335246af64f09ed4942848b5b3e6beacb966ae7f7250c655ac8
@@ -31,7 +31,7 @@ module Mongoid
31
31
  # @example Add the atomic pull.
32
32
  # person.add_atomic_pull(address)
33
33
  #
34
- # @param [ Document ] The embedded document to pull.
34
+ # @param [ Document ] document The embedded document to pull.
35
35
  #
36
36
  # @since 2.2.0
37
37
  def add_atomic_pull(document)
@@ -222,7 +222,7 @@ module Mongoid
222
222
  #
223
223
  # @since 2.1.0
224
224
  def atomic_pushes
225
- pushable? ? { atomic_position => as_document } : {}
225
+ pushable? ? { atomic_position => as_attributes } : {}
226
226
  end
227
227
 
228
228
  # Get all the attributes that need to be set.
@@ -234,7 +234,7 @@ module Mongoid
234
234
  #
235
235
  # @since 2.1.0
236
236
  def atomic_sets
237
- updateable? ? setters : settable? ? { atomic_path => as_document } : {}
237
+ updateable? ? setters : settable? ? { atomic_path => as_attributes } : {}
238
238
  end
239
239
 
240
240
  # Get all the attributes that need to be unset.
@@ -215,7 +215,6 @@ module Mongoid
215
215
  # person.attributes = { :title => "Mr." }
216
216
  #
217
217
  # @param [ Hash ] attrs The new attributes to set.
218
- # @param [ Boolean ] guard_protected_attributes False to skip mass assignment protection.
219
218
  #
220
219
  # @since 1.0.0
221
220
  def write_attributes(attrs = nil)
@@ -333,7 +332,7 @@ module Mongoid
333
332
  # the value is valid for given a field.
334
333
  # For now, only Hash and Array fields are validated.
335
334
  #
336
- # @param [ String, Symbol ] name The name of the attribute to validate.
335
+ # @param [ String, Symbol ] access The name of the attribute to validate.
337
336
  # @param [ Object ] value The to be validated.
338
337
  #
339
338
  # @since 3.0.10
@@ -13,7 +13,8 @@ module Mongoid
13
13
  # @example Does this object respond to the method?
14
14
  # person.respond_to?(:title)
15
15
  #
16
- # @param [ Array ] *args The name of the method.
16
+ # @param [ Array ] name The name of the method.
17
+ # @param [ true, false ] include_private
17
18
  #
18
19
  # @return [ true, false ] True if it does, false if not.
19
20
  #
@@ -126,7 +127,7 @@ module Mongoid
126
127
  # document.method_missing(:test)
127
128
  #
128
129
  # @param [ String, Symbol ] name The name of the method.
129
- # @param [ Array ] *args The arguments to the method.
130
+ # @param [ Array ] args The arguments to the method.
130
131
  #
131
132
  # @return [ Object ] The result of the method call.
132
133
  #
@@ -34,7 +34,7 @@ module Mongoid
34
34
  # accepts_nested_attributes_for :addresses, :game, :posts
35
35
  # end
36
36
  #
37
- # @param [ Array<Symbol>, Hash ] *args A list of relation names, followed
37
+ # @param [ Array<Symbol>, Hash ] args A list of relation names, followed
38
38
  # by a hash of options.
39
39
  #
40
40
  # @option *args [ true, false ] :allow_destroy Can deletion occur?
@@ -118,8 +118,6 @@ module Mongoid
118
118
  # @example Process the pending items.
119
119
  # document.process_pending
120
120
  #
121
- # @param [ Hash ] options The mass assignment options.
122
- #
123
121
  # @since 2.0.0.rc.7
124
122
  def process_pending
125
123
  process_nested and process_relations
@@ -132,8 +130,6 @@ module Mongoid
132
130
  # @example Process the relations.
133
131
  # document.process_relations
134
132
  #
135
- # @param [ Hash ] options The mass assignment options.
136
- #
137
133
  # @since 2.0.0.rc.7
138
134
  def process_relations
139
135
  pending_relations.each_pair do |name, value|
@@ -265,7 +265,7 @@ module Mongoid
265
265
  # Model.create_dirty_methods("name", "name")
266
266
  #
267
267
  # @param [ String ] name The name of the field.
268
- # @param [ String ] name The name of the accessor.
268
+ # @param [ String ] meth The name of the accessor.
269
269
  #
270
270
  # @return [ Module ] The fields module.
271
271
  #
@@ -38,7 +38,7 @@ module Mongoid
38
38
  def mongo_client
39
39
  persistence_context.client
40
40
  end
41
-
41
+
42
42
  def persistence_context
43
43
  PersistenceContext.get(self) ||
44
44
  PersistenceContext.get(self.class) ||
@@ -82,8 +82,10 @@ module Mongoid
82
82
  Traversable,
83
83
  Validatable,
84
84
  Equality,
85
+ Relations::Synchronization,
85
86
  ActiveModel::Model,
86
- ActiveModel::Validations
87
+ ActiveModel::Validations,
88
+ PersistenceContext
87
89
  ]
88
90
 
89
91
  # These are methods names defined in included blocks that may conflict
@@ -157,7 +157,7 @@ module Mongoid
157
157
  # @example Unset the field on the matches.
158
158
  # context.unset(:name)
159
159
  #
160
- # @param [ String, Symbol, Array ] fields The name of the fields.
160
+ # @param [ String, Symbol, Array ] args The name of the fields.
161
161
  #
162
162
  # @return [ nil ] Nil.
163
163
  #
@@ -63,9 +63,10 @@ module Mongoid
63
63
  # @example Initialize the new map/reduce.
64
64
  # MapReduce.new(criteria, map, reduce)
65
65
  #
66
+ # @param [ Mongo::Collection ] collection The collection to run the
67
+ # operation on.
66
68
  # @param [ Criteria ] criteria The Mongoid criteria.
67
- # @param [ String ] map The map js function.
68
- # @param [ String ] reduce The reduce js function.
69
+ # @param [ String ] near
69
70
  #
70
71
  # @since 3.0.0
71
72
  def initialize(collection, criteria, near)
@@ -44,7 +44,7 @@ module Mongoid
44
44
  deleted = count
45
45
  removed = map do |doc|
46
46
  prepare_remove(doc)
47
- doc.as_document
47
+ doc.send(:as_attributes)
48
48
  end
49
49
  unless removed.empty?
50
50
  collection.find(selector).update_one(
@@ -140,7 +140,7 @@ module Mongoid
140
140
  # @example Create the new context.
141
141
  # Memory.new(criteria)
142
142
  #
143
- # @param [ Criteria ] The criteria.
143
+ # @param [ Criteria ] criteria The criteria.
144
144
  #
145
145
  # @since 3.0.0
146
146
  def initialize(criteria)
@@ -148,7 +148,7 @@ module Mongoid
148
148
  @documents = criteria.documents.select do |doc|
149
149
  @root ||= doc._root
150
150
  @collection ||= root.collection
151
- doc.matches?(criteria.selector)
151
+ doc._matches?(criteria.selector)
152
152
  end
153
153
  apply_sorting
154
154
  apply_options
@@ -200,7 +200,7 @@ module Mongoid
200
200
  # @example Execute the command.
201
201
  # context.find_one_and_update({ likes: 1 })
202
202
  #
203
- # @param [ Hash ] update The updates.
203
+ # @param [ Hash ] replacement The replacement.
204
204
  # @param [ Hash ] options The command options.
205
205
  #
206
206
  # @option options [ :before, :after ] :return_document Return the updated document
@@ -239,7 +239,7 @@ module Mongoid
239
239
  # @note Automatically adding a sort on _id when no other sort is
240
240
  # defined on the criteria has the potential to cause bad performance issues.
241
241
  # If you experience unexpected poor performance when using #first or #last
242
- # and have no sort defined on the criteria, use the option { sort: :none }.
242
+ # and have no sort defined on the criteria, use the option { id_sort: :none }.
243
243
  # Be aware that #first/#last won't guarantee order in this case.
244
244
  #
245
245
  # @param [ Hash ] opts The options for the query returning the first document.
@@ -313,7 +313,7 @@ module Mongoid
313
313
  # @example Map by some field.
314
314
  # context.map(:field1)
315
315
  #
316
- # @exmaple Map with block.
316
+ # @example Map with block.
317
317
  # context.map(&:field1)
318
318
  #
319
319
  # @param [ Symbol ] field The field name.
@@ -354,7 +354,7 @@ module Mongoid
354
354
  # @note Automatically adding a sort on _id when no other sort is
355
355
  # defined on the criteria has the potential to cause bad performance issues.
356
356
  # If you experience unexpected poor performance when using #first or #last
357
- # and have no sort defined on the criteria, use the option { sort: :none }.
357
+ # and have no sort defined on the criteria, use the option { id_sort: :none }.
358
358
  # Be aware that #first/#last won't guarantee order in this case.
359
359
  #
360
360
  # @param [ Hash ] opts The options for the query returning the first document.
@@ -425,7 +425,7 @@ module Mongoid
425
425
  # @note This method will return the raw db values - it performs no custom
426
426
  # serialization.
427
427
  #
428
- # @param [ String, Symbol, Array ] field Fields to pluck.
428
+ # @param [ String, Symbol, Array ] fields Fields to pluck.
429
429
  #
430
430
  # @return [ Array<Object, Array> ] The plucked values.
431
431
  #
@@ -21,6 +21,18 @@ module Mongoid
21
21
  other.is_a?(None)
22
22
  end
23
23
 
24
+ # Allow distinct for null context.
25
+ #
26
+ # @example Get the distinct values.
27
+ # context.distinct(:name)
28
+ #
29
+ # @param [ String, Symbol ] field the name of the field.
30
+ #
31
+ # @return [ Array ] Empty Array
32
+ def distinct(field)
33
+ []
34
+ end
35
+
24
36
  # Iterate over the null context. There are no documents to iterate over
25
37
  # in this case.
26
38
  #
@@ -57,7 +69,7 @@ module Mongoid
57
69
  # @example Allow pluck for null context.
58
70
  # context.pluck(:name)
59
71
  #
60
- # @param [ String, Symbol, Array ] field or fields to pluck.
72
+ # @param [ String, Symbol, Array ] args Field or fields to pluck.
61
73
  #
62
74
  # @return [ Array ] Emtpy Array
63
75
  def pluck(*args)
@@ -69,7 +81,7 @@ module Mongoid
69
81
  # @example Create the new context.
70
82
  # Null.new(criteria)
71
83
  #
72
- # @param [ Criteria ] The criteria.
84
+ # @param [ Criteria ] criteria The criteria.
73
85
  #
74
86
  # @since 4.0.0
75
87
  def initialize(criteria)
@@ -14,8 +14,6 @@ module Mongoid
14
14
  # @example Clone the document.
15
15
  # document.clone
16
16
  #
17
- # @param [ Document ] other The document getting cloned.
18
- #
19
17
  # @return [ Document ] The new document.
20
18
  def clone
21
19
  # @note This next line is here to address #2704, even though having an
@@ -47,11 +45,9 @@ module Mongoid
47
45
  # @example clone document
48
46
  # model.clone_document
49
47
  #
50
- # @param [ Hash ] dcoument The document with hash format
51
- #
52
48
  # @since 3.0.22
53
49
  def clone_document
54
- attrs = as_document.__deep_copy__
50
+ attrs = as_attributes.__deep_copy__
55
51
  process_localized_attributes(self, attrs)
56
52
  attrs
57
53
  end
@@ -211,7 +211,7 @@ module Mongoid
211
211
  #
212
212
  # @example Merge the criteria with a hash. The hash must contain a klass
213
213
  # key and the key/value pairs correspond to method names/args.
214
-
214
+ #
215
215
  # criteria.merge({
216
216
  # klass: Band,
217
217
  # where: { name: "Depeche Mode" },
@@ -389,7 +389,7 @@ module Mongoid
389
389
  # @example Add a javascript selection.
390
390
  # criteria.where("this.name == 'syd'")
391
391
  #
392
- # @param [ String, Hash ] criterion The javascript or standard selection.
392
+ # @param [ String, Hash ] expression The javascript or standard selection.
393
393
  #
394
394
  # @raise [ UnsupportedJavascript ] If provided a string and the criteria
395
395
  # is embedded.
@@ -8,7 +8,8 @@ module Mongoid
8
8
  # @example Execute or raise
9
9
  # criteria.execute_or_raise(id)
10
10
  #
11
- # @param [ Object ] args The arguments passed.
11
+ # @param [ Object ] ids The arguments passed.
12
+ # @param [ true, false ] multi Whether there arguments were a list.
12
13
  #
13
14
  # @raise [ Errors::DocumentNotFound ] If nothing returned.
14
15
  #
@@ -66,7 +67,7 @@ module Mongoid
66
67
  # @example Get the documents from the map or criteria.
67
68
  # criteria.multiple_from_map_or_db(ids)
68
69
  #
69
- # @param [ ids ] The searched ids.
70
+ # @param [ Array<Object> ] ids The searched ids.
70
71
  #
71
72
  # @return [ Array<Document> ] The found documents.
72
73
  def multiple_from_db(ids)
@@ -48,7 +48,7 @@ module Mongoid
48
48
  # @example Set the inclusions.
49
49
  # criteria.inclusions = [ meta ]
50
50
  #
51
- # @param [ Array<Metadata> ] The inclusions.
51
+ # @param [ Array<Metadata> ] value The inclusions.
52
52
  #
53
53
  # @return [ Array<Metadata> ] The new inclusions.
54
54
  #
@@ -65,7 +65,7 @@ module Mongoid
65
65
  # criteria.add_inclusion(Person, :posts)
66
66
  #
67
67
  # @param [ Class, String, Symbol ] _klass The class or string/symbol of the class name.
68
- # @param [ Symbol ] relation The relation.
68
+ # @param [ Symbol ] metadata The relation.
69
69
  #
70
70
  # @raise [ Errors::InvalidIncludes ] If no relation is found.
71
71
  #
@@ -60,7 +60,7 @@ module Mongoid
60
60
  # @example Add a projection to the pipeline.
61
61
  # aggregable.project(author: 1, name: 0)
62
62
  #
63
- # @param [ Hash ] criterion The projection to make.
63
+ # @param [ Hash ] operation The projection to make.
64
64
  #
65
65
  # @return [ Aggregable ] The aggregable.
66
66
  #
@@ -162,7 +162,7 @@ module Mongoid
162
162
  # @example Evolve the object.
163
163
  # Array.evolve(1)
164
164
  #
165
- # @param [ Object ] The object to evolve.
165
+ # @param [ Object ] object The object to evolve.
166
166
  #
167
167
  # @return [ Object ] The evolved object.
168
168
  #
@@ -14,7 +14,7 @@ module Mongoid
14
14
  # @example Evolve the value to a boolean.
15
15
  # Boolean.evolve(true)
16
16
  #
17
- # @param [ Object ] The object to evolve.
17
+ # @param [ Object ] object The object to evolve.
18
18
  #
19
19
  # @return [ true, false ] The boolean value.
20
20
  #
@@ -26,7 +26,7 @@ module Mongoid
26
26
  # @example Merge the hash into the array.
27
27
  # { field: value }.__add_from_array__([ 1, 2 ])
28
28
  #
29
- # @param [ Array ] value The array to add to.
29
+ # @param [ Array ] array The array to add to.
30
30
  #
31
31
  # @return [ Hash ] The merged hash.
32
32
  #
@@ -54,7 +54,7 @@ module Mongoid
54
54
  # @example Merge the hash into the array.
55
55
  # { field: value }.__intersect_from_array__([ 1, 2 ])
56
56
  #
57
- # @param [ Array ] value The array to intersect to.
57
+ # @param [ Array ] array The array to intersect to.
58
58
  #
59
59
  # @return [ Hash ] The merged hash.
60
60
  #
@@ -68,7 +68,7 @@ module Mongoid
68
68
  # @example Merge the hash into the object.
69
69
  # { field: value }.__intersect_from_object__([ 1, 2 ])
70
70
  #
71
- # @param [ Object ] value The object to intersect to.
71
+ # @param [ Object ] object The object to intersect to.
72
72
  #
73
73
  # @return [ Hash ] The merged hash.
74
74
  #
@@ -96,7 +96,7 @@ module Mongoid
96
96
  # @example Merge the hash into the object.
97
97
  # { field: value }.__union_from_object__([ 1, 2 ])
98
98
  #
99
- # @param [ Object ] value The object to union to.
99
+ # @param [ Object ] object The object to union to.
100
100
  #
101
101
  # @return [ Hash ] The merged hash.
102
102
  #
@@ -26,7 +26,7 @@ module Mongoid
26
26
  # @example Merge the object into the array.
27
27
  # 4.__add_from_array__([ 1, 2 ])
28
28
  #
29
- # @param [ Array ] value The array to add to.
29
+ # @param [ Array ] array The array to add to.
30
30
  #
31
31
  # @return [ Array ] The merged object.
32
32
  #
@@ -54,7 +54,7 @@ module Mongoid
54
54
  # @example Merge the object into the array.
55
55
  # 4.__intersect_from_array__([ 1, 2 ])
56
56
  #
57
- # @param [ Array ] value The array to intersect to.
57
+ # @param [ Array ] array The array to intersect to.
58
58
  #
59
59
  # @return [ Array ] The merged object.
60
60
  #
@@ -68,7 +68,7 @@ module Mongoid
68
68
  # @example Merge the object into the array.
69
69
  # 4.__intersect_from_object__([ 1, 2 ])
70
70
  #
71
- # @param [ Object ] value The value to intersect to.
71
+ # @param [ Object ] object The value to intersect to.
72
72
  #
73
73
  # @return [ Array ] The merged object.
74
74
  #
@@ -96,7 +96,7 @@ module Mongoid
96
96
  # @example Merge the object into the array.
97
97
  # 4.__union_from_object__([ 1, 2 ])
98
98
  #
99
- # @param [ Object ] value The value to union to.
99
+ # @param [ Object ] object The value to union to.
100
100
  #
101
101
  # @return [ Array ] The merged object.
102
102
  #
@@ -35,6 +35,38 @@ module Mongoid
35
35
  end
36
36
  end
37
37
  end
38
+
39
+ module Raw
40
+
41
+ # Is the object a regexp?
42
+ #
43
+ # @example Is the object a regex?
44
+ # bson_raw_regexp.regexp?
45
+ #
46
+ # @return [ true ] Always true.
47
+ #
48
+ # @since 5.2.1
49
+ def regexp?; true; end
50
+
51
+ module ClassMethods
52
+
53
+ # Evolve the object into a raw bson regex.
54
+ #
55
+ # @example Evolve the object to a regex.
56
+ # BSON::Regexp::Raw.evolve("^[123]")
57
+ #
58
+ # @param [ BSON::Regexp::Raw, String ] object The object to evolve.
59
+ #
60
+ # @return [ BSON::Regexp::Raw ] The evolved raw regex.
61
+ #
62
+ # @since 5.2.1
63
+ def evolve(object)
64
+ __evolve__(object) do |obj|
65
+ obj.is_a?(String) ? BSON::Regexp::Raw.new(obj) : obj
66
+ end
67
+ end
68
+ end
69
+ end
38
70
  end
39
71
  end
40
72
  end
@@ -43,3 +75,5 @@ end
43
75
 
44
76
  ::Regexp.__send__(:include,Mongoid::Criteria::Queryable::Extensions::Regexp)
45
77
  ::Regexp.__send__(:extend, Mongoid::Criteria::Queryable::Extensions::Regexp::ClassMethods)
78
+ BSON::Regexp::Raw.__send__(:include,Mongoid::Criteria::Queryable::Extensions::Regexp::Raw)
79
+ BSON::Regexp::Raw.__send__(:extend, Mongoid::Criteria::Queryable::Extensions::Regexp::Raw::ClassMethods)