mongoid 6.1.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/atomic.rb +3 -3
- data/lib/mongoid/attributes.rb +1 -2
- data/lib/mongoid/attributes/dynamic.rb +3 -2
- data/lib/mongoid/attributes/nested.rb +1 -1
- data/lib/mongoid/attributes/processing.rb +0 -4
- data/lib/mongoid/changeable.rb +1 -1
- data/lib/mongoid/clients/options.rb +1 -1
- data/lib/mongoid/composable.rb +3 -1
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/geo_near.rb +3 -2
- data/lib/mongoid/contextual/memory.rb +3 -3
- data/lib/mongoid/contextual/mongo.rb +5 -5
- data/lib/mongoid/contextual/none.rb +14 -2
- data/lib/mongoid/copyable.rb +1 -5
- data/lib/mongoid/criteria.rb +2 -2
- data/lib/mongoid/criteria/findable.rb +3 -2
- data/lib/mongoid/criteria/includable.rb +2 -2
- data/lib/mongoid/criteria/queryable/aggregable.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/array.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/hash.rb +4 -4
- data/lib/mongoid/criteria/queryable/extensions/object.rb +4 -4
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +34 -0
- data/lib/mongoid/criteria/queryable/options.rb +16 -0
- data/lib/mongoid/criteria/queryable/selector.rb +1 -1
- data/lib/mongoid/document.rb +1 -1
- data/lib/mongoid/errors/delete_restriction.rb +2 -2
- data/lib/mongoid/errors/inverse_not_found.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +3 -2
- data/lib/mongoid/extensions/object.rb +2 -2
- data/lib/mongoid/extensions/time.rb +1 -1
- data/lib/mongoid/factory.rb +0 -1
- data/lib/mongoid/fields/foreign_key.rb +2 -2
- data/lib/mongoid/findable.rb +1 -1
- data/lib/mongoid/indexable.rb +3 -2
- data/lib/mongoid/indexable/specification.rb +1 -1
- data/lib/mongoid/interceptable.rb +3 -9
- data/lib/mongoid/loggable.rb +1 -1
- data/lib/mongoid/matchable.rb +16 -9
- data/lib/mongoid/matchable/all.rb +2 -2
- data/lib/mongoid/matchable/and.rb +3 -3
- data/lib/mongoid/matchable/default.rb +2 -2
- data/lib/mongoid/matchable/elem_match.rb +3 -3
- data/lib/mongoid/matchable/exists.rb +2 -2
- data/lib/mongoid/matchable/gt.rb +2 -2
- data/lib/mongoid/matchable/gte.rb +2 -2
- data/lib/mongoid/matchable/in.rb +2 -2
- data/lib/mongoid/matchable/lt.rb +2 -2
- data/lib/mongoid/matchable/lte.rb +2 -2
- data/lib/mongoid/matchable/ne.rb +2 -2
- data/lib/mongoid/matchable/nin.rb +2 -2
- data/lib/mongoid/matchable/or.rb +3 -3
- data/lib/mongoid/matchable/regexp.rb +27 -0
- data/lib/mongoid/matchable/size.rb +2 -2
- data/lib/mongoid/persistable.rb +0 -3
- data/lib/mongoid/persistable/creatable.rb +2 -4
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +1 -1
- data/lib/mongoid/persistable/upsertable.rb +1 -1
- data/lib/mongoid/persistence_context.rb +2 -3
- data/lib/mongoid/relations/accessors.rb +1 -2
- data/lib/mongoid/relations/bindings/embedded/in.rb +0 -4
- data/lib/mongoid/relations/bindings/embedded/many.rb +1 -8
- data/lib/mongoid/relations/bindings/embedded/one.rb +0 -10
- data/lib/mongoid/relations/bindings/referenced/many.rb +0 -4
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +4 -4
- data/lib/mongoid/relations/builders/embedded/one.rb +1 -1
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +1 -1
- data/lib/mongoid/relations/conversions.rb +1 -1
- data/lib/mongoid/relations/counter_cache.rb +10 -10
- data/lib/mongoid/relations/eager.rb +6 -11
- data/lib/mongoid/relations/eager/base.rb +4 -4
- data/lib/mongoid/relations/embedded/batchable.rb +3 -3
- data/lib/mongoid/relations/embedded/in.rb +1 -3
- data/lib/mongoid/relations/embedded/many.rb +12 -9
- data/lib/mongoid/relations/embedded/one.rb +1 -3
- data/lib/mongoid/relations/macros.rb +3 -2
- data/lib/mongoid/relations/metadata.rb +3 -3
- data/lib/mongoid/relations/nested_builder.rb +1 -1
- data/lib/mongoid/relations/proxy.rb +3 -2
- data/lib/mongoid/relations/referenced/in.rb +1 -4
- data/lib/mongoid/relations/referenced/many.rb +5 -7
- data/lib/mongoid/relations/referenced/many_to_many.rb +2 -2
- data/lib/mongoid/relations/referenced/one.rb +0 -2
- data/lib/mongoid/relations/reflections.rb +2 -2
- data/lib/mongoid/relations/synchronization.rb +11 -11
- data/lib/mongoid/scopable.rb +2 -2
- data/lib/mongoid/serializable.rb +4 -3
- data/lib/mongoid/tasks/database.rb +2 -1
- data/lib/mongoid/threaded.rb +4 -4
- data/lib/mongoid/validatable.rb +1 -1
- data/lib/mongoid/validatable/macros.rb +4 -2
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +12 -2
- data/spec/app/models/book.rb +2 -1
- data/spec/app/models/page.rb +1 -1
- data/spec/mongoid/contextual/none_spec.rb +15 -0
- data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +89 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +15 -0
- data/spec/mongoid/criteria_spec.rb +6 -2
- data/spec/mongoid/interceptable_spec.rb +19 -0
- data/spec/mongoid/matchable/all_spec.rb +4 -4
- data/spec/mongoid/matchable/and_spec.rb +10 -10
- data/spec/mongoid/matchable/default_spec.rb +12 -12
- data/spec/mongoid/matchable/elem_match_spec.rb +11 -11
- data/spec/mongoid/matchable/exists_spec.rb +5 -5
- data/spec/mongoid/matchable/gt_spec.rb +8 -8
- data/spec/mongoid/matchable/gte_spec.rb +8 -8
- data/spec/mongoid/matchable/in_spec.rb +5 -5
- data/spec/mongoid/matchable/lt_spec.rb +8 -8
- data/spec/mongoid/matchable/lte_spec.rb +8 -8
- data/spec/mongoid/matchable/ne_spec.rb +5 -5
- data/spec/mongoid/matchable/nin_spec.rb +5 -5
- data/spec/mongoid/matchable/or_spec.rb +7 -7
- data/spec/mongoid/matchable/regexp_spec.rb +59 -0
- data/spec/mongoid/matchable/size_spec.rb +3 -3
- data/spec/mongoid/matchable_spec.rb +108 -58
- data/spec/mongoid/persistable/deletable_spec.rb +15 -0
- data/spec/mongoid/persistable/settable_spec.rb +16 -0
- data/spec/mongoid/persistence_context_spec.rb +22 -1
- data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +4 -4
- data/spec/mongoid/relations/embedded/many_spec.rb +24 -6
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +1 -1
- data/spec/mongoid/relations/synchronization_spec.rb +48 -2
- data/spec/mongoid/relations/touchable_spec.rb +40 -0
- data/spec/mongoid/validatable/uniqueness_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- metadata +9 -26
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df15f3d764e3c19bcc5719c656f833ce258bb65
|
4
|
+
data.tar.gz: 335173b371125d1e84100af19293bccf459df5b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fabe8ac17c05be402c8dd42bff52a4158e0a0d0650cd36363a7439ea19e32d0a3b28427b85fb88749df2941d2ba5fa4c639aa74f9b70ef0e4875acd4438ae6
|
7
|
+
data.tar.gz: 40cf34caa79067109baeee5b434f8e2497c654a91248a73a220ac1ded8d685fbc3ea13adaa0e4335246af64f09ed4942848b5b3e6beacb966ae7f7250c655ac8
|
data/lib/mongoid/atomic.rb
CHANGED
@@ -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 =>
|
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 =>
|
237
|
+
updateable? ? setters : settable? ? { atomic_path => as_attributes } : {}
|
238
238
|
end
|
239
239
|
|
240
240
|
# Get all the attributes that need to be unset.
|
data/lib/mongoid/attributes.rb
CHANGED
@@ -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 ]
|
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 ]
|
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 ]
|
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 ]
|
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|
|
data/lib/mongoid/changeable.rb
CHANGED
@@ -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 ]
|
268
|
+
# @param [ String ] meth The name of the accessor.
|
269
269
|
#
|
270
270
|
# @return [ Module ] The fields module.
|
271
271
|
#
|
data/lib/mongoid/composable.rb
CHANGED
@@ -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 ]
|
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 ]
|
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.
|
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.
|
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 ]
|
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 {
|
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
|
-
# @
|
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 {
|
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 ]
|
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 ]
|
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)
|
data/lib/mongoid/copyable.rb
CHANGED
@@ -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 =
|
50
|
+
attrs = as_attributes.__deep_copy__
|
55
51
|
process_localized_attributes(self, attrs)
|
56
52
|
attrs
|
57
53
|
end
|
data/lib/mongoid/criteria.rb
CHANGED
@@ -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 ]
|
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 ]
|
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 [
|
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 ]
|
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 ]
|
63
|
+
# @param [ Hash ] operation The projection to make.
|
64
64
|
#
|
65
65
|
# @return [ Aggregable ] The aggregable.
|
66
66
|
#
|
@@ -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 ]
|
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 ]
|
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 ]
|
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 ]
|
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 ]
|
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 ]
|
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 ]
|
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 ]
|
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)
|