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
@@ -88,6 +88,22 @@ module Mongoid
88
88
  pipeline
89
89
  end
90
90
 
91
+ # Perform a deep copy of the options.
92
+ #
93
+ # @example Perform a deep copy.
94
+ # options.__deep_copy__
95
+ #
96
+ # @return [ Options ] The copied options.
97
+ #
98
+ # @since 6.1.1
99
+ def __deep_copy__
100
+ self.class.new(aliases, serializers) do |copy|
101
+ each_pair do |key, value|
102
+ copy.merge!(key => value.__deep_copy__)
103
+ end
104
+ end
105
+ end
106
+
91
107
  private
92
108
 
93
109
  # Evolve a single key selection with various types of values.
@@ -83,7 +83,7 @@ module Mongoid
83
83
  # @example Evolve the multi-selection.
84
84
  # selector.evolve_multi([{ field: "value" }])
85
85
  #
86
- # @param [ Array<Hash> ] The multi-selection.
86
+ # @param [ Array<Hash> ] value The multi-selection.
87
87
  #
88
88
  # @return [ Array<Hash> ] The serialized values.
89
89
  #
@@ -282,7 +282,7 @@ module Mongoid
282
282
  relation, stored = send(name), meta.store_as
283
283
  if attributes.key?(stored) || !relation.blank?
284
284
  if relation
285
- attributes[stored] = relation.as_document
285
+ attributes[stored] = relation.send(:as_attributes)
286
286
  else
287
287
  attributes.delete(stored)
288
288
  end
@@ -11,8 +11,8 @@ module Mongoid
11
11
  # @example Create the new callbacks error.
12
12
  # Callbacks.new(Post, :create!)
13
13
  #
14
- # @param [ Class ] klass The class of the document.
15
- # @param [ Symbol ] method The name of the method.
14
+ # @param [ Class ] document
15
+ # @param [ Symbol ] relation
16
16
  #
17
17
  # @since 3.0.0
18
18
  def initialize(document, relation)
@@ -12,7 +12,7 @@ module Mongoid
12
12
  #
13
13
  # @param [ Class ] base The base class.
14
14
  # @param [ Symbol ] name The name of the relation.
15
- # @param [ Class ] The child class.
15
+ # @param [ Class ] klass The child class.
16
16
  # @param [ Symbol ] inverse The attempted inverse key.
17
17
  #
18
18
  # @since 3.0.0
@@ -162,10 +162,11 @@ module Mongoid
162
162
  # @api private
163
163
  #
164
164
  # @example Mongoize for the klass, field and value.
165
- # {}.mongoize_for(Band, "name", "test")
165
+ # {}.mongoize_for("$push", Band, "name", "test")
166
166
  #
167
+ # @param [ String ] operator The operator.
167
168
  # @param [ Class ] klass The model class.
168
- # @param [ String, Symbol ] The field key.
169
+ # @param [ String, Symbol ] key The field key.
169
170
  # @param [ Object ] value The value to mongoize.
170
171
  #
171
172
  # @return [ Object ] The mongoized value.
@@ -94,7 +94,7 @@ module Mongoid
94
94
  # object.do_or_do_not(:use, "The Force")
95
95
  #
96
96
  # @param [ String, Symbol ] name The method name.
97
- # @param [ Array ] *args The arguments.
97
+ # @param [ Array ] args The arguments.
98
98
  #
99
99
  # @return [ Object, nil ] The result of the method call or nil if the
100
100
  # method does not exist.
@@ -209,7 +209,7 @@ module Mongoid
209
209
  # object.you_must(:use, "The Force")
210
210
  #
211
211
  # @param [ String, Symbol ] name The method name.
212
- # @param [ Array ] *args The arguments.
212
+ # @param [ Array ] args The arguments.
213
213
  #
214
214
  # @return [ Object, nil ] The result of the method call or nil if the
215
215
  # method does not exist. Nil if the object is frozen.
@@ -30,7 +30,7 @@ module Mongoid
30
30
  # @example Get the configured time.
31
31
  # ::Time.configured
32
32
  #
33
- # @retun [ Time ] The configured time.
33
+ # @return [ Time ] The configured time.
34
34
  #
35
35
  # @since 3.0.0
36
36
  def configured
@@ -14,7 +14,6 @@ module Mongoid
14
14
  #
15
15
  # @param [ Class ] klass The class to instantiate from if _type is not present.
16
16
  # @param [ Hash ] attributes The document attributes.
17
- # @param [ Hash ] options The mass assignment scoping options.
18
17
  #
19
18
  # @return [ Document ] The instantiated document.
20
19
  def build(klass, attributes = nil)
@@ -14,8 +14,8 @@ module Mongoid
14
14
  # @param [ String ] name The name of the field.
15
15
  # @param [ String ] key The atomic location of the field.
16
16
  # @param [ Hash ] mods The current modifications.
17
- # @param [ Array ] new The new elements to add.
18
- # @param [ Array ] old The old elements getting removed.
17
+ # @param [ Array ] new_elements The new elements to add.
18
+ # @param [ Array ] old_elements The old elements getting removed.
19
19
  #
20
20
  # @since 2.4.0
21
21
  def add_atomic_changes(document, name, key, mods, new_elements, old_elements)
@@ -71,7 +71,7 @@ module Mongoid
71
71
  # @example Do any documents exist for the conditions?
72
72
  # Person.exists?
73
73
  #
74
- # @param [ Array ] args The conditions.
74
+ # @return [ true, false ] If any documents exist for the conditions.
75
75
  def exists?
76
76
  with_default_scope.exists?
77
77
  end
@@ -92,7 +92,7 @@ module Mongoid
92
92
  # index({ name: 1 }, { background: true })
93
93
  # end
94
94
  #
95
- # @param [ Symbol ] name The name of the field.
95
+ # @param [ Symbol ] spec The index spec.
96
96
  # @param [ Hash ] options The index options.
97
97
  #
98
98
  # @return [ Hash ] The index options.
@@ -110,7 +110,8 @@ module Mongoid
110
110
  # @example Get the index specification.
111
111
  # Model.index_specification(name: 1)
112
112
  #
113
- # @param [ Hash ] key The index key/direction pair.
113
+ # @param [ Hash ] index_hash The index key/direction pair.
114
+ # @param [ String ] index_name The index name.
114
115
  #
115
116
  # @return [ Specification ] The found specification.
116
117
  #
@@ -99,7 +99,7 @@ module Mongoid
99
99
  # @example Normalize the index options.
100
100
  # specification.normalize_options(drop_dups: true)
101
101
  #
102
- # @param [ Hash ] options The index options.
102
+ # @param [ Hash ] opts The index options.
103
103
  #
104
104
  # @return [ Hash ] The normalized options.
105
105
  #
@@ -46,7 +46,7 @@ module Mongoid
46
46
  # @example Is the callback executable?
47
47
  # document.callback_executable?(:save)
48
48
  #
49
- # @param [ Symbol ] kin The type of callback.
49
+ # @param [ Symbol ] kind The type of callback.
50
50
  #
51
51
  # @return [ true, false ] If the callback can be executed.
52
52
  #
@@ -118,19 +118,13 @@ module Mongoid
118
118
  # end
119
119
  #
120
120
  # @param [ Symbol ] kind The type of callback to execute.
121
- # @param [ Array ] *args Any options.
121
+ # @param [ Array ] args Any options.
122
122
  #
123
123
  # @return [ Document ] The document
124
124
  #
125
125
  # @since 2.3.0
126
126
  def run_callbacks(kind, *args, &block)
127
127
  cascadable_children(kind).each do |child|
128
- # This is returning false for some destroy tests on 4.1.0.beta1,
129
- # causing them to fail since 4.1.0 expects a block to be passed if the
130
- # callbacks for the type are empty. If no block is passed then the nil
131
- # return value gets interpreted as false and halts the chain.
132
- #
133
- # @see https://github.com/rails/rails/blob/master/activesupport/lib/active_support/callbacks.rb#L79
134
128
  if child.run_callbacks(child_callback_type(kind, child), *args) == false
135
129
  return false
136
130
  end
@@ -196,7 +190,7 @@ module Mongoid
196
190
  #
197
191
  # @since 2.3.0
198
192
  def cascadable_child?(kind, child, metadata)
199
- return false if kind == :initialize || kind == :find
193
+ return false if kind == :initialize || kind == :find || kind == :touch
200
194
  return false if kind == :validate && metadata.validate?
201
195
  child.callback_executable?(kind) ? child.in_callback_state?(kind) : false
202
196
  end
@@ -25,7 +25,7 @@ module Mongoid
25
25
  # @example Set the logger.
26
26
  # Loggable.logger = Logger.new($stdout)
27
27
  #
28
- # @param [ Logger ] The logger to set.
28
+ # @param [ Logger ] logger The logger to set.
29
29
  #
30
30
  # @return [ Logger ] The new logger.
31
31
  #
@@ -13,6 +13,7 @@ require "mongoid/matchable/nin"
13
13
  require "mongoid/matchable/or"
14
14
  require "mongoid/matchable/size"
15
15
  require "mongoid/matchable/elem_match"
16
+ require "mongoid/matchable/regexp"
16
17
 
17
18
  module Mongoid
18
19
 
@@ -46,26 +47,26 @@ module Mongoid
46
47
  # MongoDB selector. Used for matching on embedded associations.
47
48
  #
48
49
  # @example Does the document match?
49
- # document.matches?(:title => { "$in" => [ "test" ] })
50
+ # document._matches?(:title => { "$in" => [ "test" ] })
50
51
  #
51
52
  # @param [ Hash ] selector The MongoDB selector.
52
53
  #
53
54
  # @return [ true, false ] True if matches, false if not.
54
55
  #
55
56
  # @since 1.0.0
56
- def matches?(selector)
57
+ def _matches?(selector)
57
58
  selector.each_pair do |key, value|
58
59
  if value.is_a?(Hash)
59
60
  value.each do |item|
60
61
  if item[0].to_s == "$not".freeze
61
62
  item = item[1]
62
- return false if matcher(self, key, item).matches?(item)
63
+ return false if matcher(self, key, item)._matches?(item)
63
64
  else
64
- return false unless matcher(self, key, Hash[*item]).matches?(Hash[*item])
65
+ return false unless matcher(self, key, Hash[*item])._matches?(Hash[*item])
65
66
  end
66
67
  end
67
68
  else
68
- return false unless matcher(self, key, value).matches?(value)
69
+ return false unless matcher(self, key, value)._matches?(value)
69
70
  end
70
71
  end
71
72
  true
@@ -83,7 +84,7 @@ module Mongoid
83
84
  #
84
85
  # @param [ Document ] document The document to check.
85
86
  # @param [ Symbol, String ] key The field name.
86
- # @param [ Object, Hash ] The value or selector.
87
+ # @param [ Object, Hash ] value The value or selector.
87
88
  #
88
89
  # @return [ Matcher ] The matcher.
89
90
  #
@@ -104,7 +105,7 @@ module Mongoid
104
105
  #
105
106
  # @param [ Document ] document The document to check.
106
107
  # @param [ Symbol, String ] key The field name.
107
- # @param [ Object, Hash ] The value or selector.
108
+ # @param [ Object, Hash ] value The value or selector.
108
109
  #
109
110
  # @return [ Matcher ] The matcher.
110
111
  #
@@ -117,6 +118,8 @@ module Mongoid
117
118
  else
118
119
  Default.new(extract_attribute(document, key))
119
120
  end
121
+ elsif value.regexp?
122
+ Regexp.new(extract_attribute(document, key))
120
123
  else
121
124
  case key.to_s
122
125
  when "$or" then Or.new(value, document)
@@ -143,9 +146,13 @@ module Mongoid
143
146
  # @since 2.2.1
144
147
  def extract_attribute(document, key)
145
148
  if (key_string = key.to_s) =~ /.+\..+/
146
- key_string.split('.').inject(document.as_document) do |_attribs, _key|
149
+ key_string.split('.').inject(document.send(:as_attributes)) do |_attribs, _key|
147
150
  if _attribs.is_a?(::Array)
148
- _attribs.map { |doc| doc.try(:[], _key) }
151
+ if _key =~ /\A\d+\z/ && _attribs.none? {|doc| doc.is_a?(Hash)}
152
+ _attribs.try(:[], _key.to_i)
153
+ else
154
+ _attribs.map { |doc| doc.try(:[], _key) }
155
+ end
149
156
  else
150
157
  _attribs.try(:[], _key)
151
158
  end
@@ -8,12 +8,12 @@ module Mongoid
8
8
  # Return true if the attribute and first value in the hash are equal.
9
9
  #
10
10
  # @example Do the values match?
11
- # matcher.matches?({ :key => 10 })
11
+ # matcher._matches?({ :key => 10 })
12
12
  #
13
13
  # @param [ Hash ] value The values to check.
14
14
  #
15
15
  # @return [ true, false ] If the values match.
16
- def matches?(value)
16
+ def _matches?(value)
17
17
  first = first(value)
18
18
  return false if first.is_a?(Array) && first.empty?
19
19
 
@@ -8,19 +8,19 @@ module Mongoid
8
8
  # Does the supplied query match the attribute?
9
9
  #
10
10
  # @example Does this match?
11
- # matcher.matches?([ { field => value } ])
11
+ # matcher._matches?([ { field => value } ])
12
12
  #
13
13
  # @param [ Array ] conditions The or expression.
14
14
  #
15
15
  # @return [ true, false ] True if matches, false if not.
16
16
  #
17
17
  # @since 2.3.0
18
- def matches?(conditions)
18
+ def _matches?(conditions)
19
19
  conditions.each do |condition|
20
20
  condition.keys.each do |k|
21
21
  key = k
22
22
  value = condition[k]
23
- return false unless document.matches?(key => value)
23
+ return false unless document._matches?(key => value)
24
24
  end
25
25
  end
26
26
  true
@@ -24,14 +24,14 @@ module Mongoid
24
24
  # if the value is included.
25
25
  #
26
26
  # @example Does this value match?
27
- # default.matches?("value")
27
+ # default._matches?("value")
28
28
  #
29
29
  # @param [ Object ] value The value to check if it matches.
30
30
  #
31
31
  # @return [ true, false ] True if matches, false if not.
32
32
  #
33
33
  # @since 1.0.0
34
- def matches?(value)
34
+ def _matches?(value)
35
35
  attribute.is_a?(Array) && !value.is_a?(Array) ? attribute.any? { |_attribute| value === _attribute } : value === attribute
36
36
  end
37
37
 
@@ -7,19 +7,19 @@ module Mongoid
7
7
  # Return true if a given predicate matches a sub document entirely
8
8
  #
9
9
  # @example Do the values match?
10
- # matcher.matches?({"$elemMatch" => {"a" => 1, "b" => 2}})
10
+ # matcher._matches?({"$elemMatch" => {"a" => 1, "b" => 2}})
11
11
  #
12
12
  # @param [ Hash ] value The values to check.
13
13
  #
14
14
  # @return [ true, false ] If the values match.
15
- def matches?(value)
15
+ def _matches?(value)
16
16
  if !@attribute.is_a?(Array) || !value.kind_of?(Hash) || !value["$elemMatch"].kind_of?(Hash)
17
17
  return false
18
18
  end
19
19
 
20
20
  return @attribute.any? do |sub_document|
21
21
  value["$elemMatch"].all? do |k, v|
22
- Matchable.matcher(sub_document, k, v).matches?(v)
22
+ Matchable.matcher(sub_document, k, v)._matches?(v)
23
23
  end
24
24
  end
25
25
  end
@@ -10,12 +10,12 @@ module Mongoid
10
10
  # non-existence.
11
11
  #
12
12
  # @example Does anything exist?
13
- # matcher.matches?({ :key => 10 })
13
+ # matcher._matches?({ :key => 10 })
14
14
  #
15
15
  # @param [ Hash ] value The values to check.
16
16
  #
17
17
  # @return [ true, false ] If a value exists.
18
- def matches?(value)
18
+ def _matches?(value)
19
19
  @attribute.nil? != value.values.first
20
20
  end
21
21
  end
@@ -8,12 +8,12 @@ module Mongoid
8
8
  # Return true if the attribute is greater than the value.
9
9
  #
10
10
  # @example Do the values match?
11
- # matcher.matches?({ :key => 10 })
11
+ # matcher._matches?({ :key => 10 })
12
12
  #
13
13
  # @param [ Hash ] value The values to check.
14
14
  #
15
15
  # @return [ true, false ] If a value exists.
16
- def matches?(value)
16
+ def _matches?(value)
17
17
  determine(value, :>)
18
18
  rescue ArgumentError
19
19
  false
@@ -8,12 +8,12 @@ module Mongoid
8
8
  # Return true if the attribute is greater than or equal to the value.
9
9
  #
10
10
  # @example Do the values match?
11
- # matcher.matches?({ :key => 10 })
11
+ # matcher._matches?({ :key => 10 })
12
12
  #
13
13
  # @param [ Hash ] value The values to check.
14
14
  #
15
15
  # @return [ true, false ] If a value exists.
16
- def matches?(value)
16
+ def _matches?(value)
17
17
  determine(value, :>=)
18
18
  rescue ArgumentError
19
19
  false
@@ -8,12 +8,12 @@ module Mongoid
8
8
  # Return true if the attribute is in the values.
9
9
  #
10
10
  # @example Do the values match?
11
- # matcher.matches?({ :key => 10 })
11
+ # matcher._matches?({ :key => 10 })
12
12
  #
13
13
  # @param [ Hash ] value The values to check.
14
14
  #
15
15
  # @return [ true, false ] If a value exists.
16
- def matches?(value)
16
+ def _matches?(value)
17
17
  attribute_array = @attribute.nil? ? [nil] : Array.wrap(@attribute)
18
18
  value.values.first.any? do |e|
19
19
  attribute_array.any? { |_attribute| e === _attribute }
@@ -8,12 +8,12 @@ module Mongoid
8
8
  # Return true if the attribute is less than the value.
9
9
  #
10
10
  # @example Do the values match?
11
- # matcher.matches?({ :key => 10 })
11
+ # matcher._matches?({ :key => 10 })
12
12
  #
13
13
  # @param [ Hash ] value The values to check.
14
14
  #
15
15
  # @return [ true, false ] If a value exists.
16
- def matches?(value)
16
+ def _matches?(value)
17
17
  determine(value, :<)
18
18
  rescue ArgumentError
19
19
  false