mongory 0.9.0-x86_64-linux → 0.9.1-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82611864cabc7bcecdf6060fe50204c53a0fc42129d855886d430415d48f9cf5
4
- data.tar.gz: 067512057602f4f3aefeaac2587e32e7ac26cc34328b8dbef2115c0633bd9a83
3
+ metadata.gz: 46ad0b547dc5520b248353952d9f02c9c293a98f681d1434f3d327e755dd0ecf
4
+ data.tar.gz: 2fa00f65ee0b4cd354688eb2e214734d2a608ea69ee6244c83b5f8a4cabb92de
5
5
  SHA512:
6
- metadata.gz: 457063ab8b05421b0e1d8d10a9687614131f7adf275fba6323748bb88204c9066cc39f286f23c17be9170b674de0184c125e52f67a106dcabcd883b3c0916b7e
7
- data.tar.gz: e0e2b6dbedec32f6be244e3f5f66d88d88855261c254ba4f1a9012c10b6efce12bbfa29a0fa93a5c720198915fae82a37353417dd86151f77cdd473bd68035ac
6
+ metadata.gz: 8d2cdff58369c3ce2f72bd4030cce9e36bca1333d5257cf0daed1e3629add3a6e37ef6ae69269170bf480dc7eaf7cdaa4c23be866ff1412c8f99cff9bea38334
7
+ data.tar.gz: db2ae0572dd53339b6e6e84767ad86f9a6adba175af9ddf06332ef391e7138a481baba7bf136dcddf0319fc4cc0d8eeddad8771a4888278f14eda9b0fd42a25b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.1] - 2026-11-18
4
+
5
+ Aligns with `mongory-core` `v0.2.1`.
6
+
7
+ ### Fixes
8
+ - **`QueryMatcher` (`LiteralMatcher` & `AbstractMultiMatcher`)**:
9
+ - Reflect lazily built `array_record_matcher` priority in `LiteralMatcher#priority` and `render_tree`.
10
+ - Propagate priority increases up enclosing matchers (`FieldMatcher`, `NotMatcher`, `SizeMatcher`, `ElemMatchMatcher`, `EveryMatcher`, `HashConditionMatcher`, `AndMatcher`, `OrMatcher`, `ArrayRecordMatcher`, `QueryMatcher`), stably re-sort child `@matchers`, and invalidate memoized `@cached_proc` / `@debug_proc` closures so subsequent evaluations short-circuit on cheaper conditions first.
11
+ - **Core (`mongory-core` submodule `v0.2.1`)**:
12
+ - Propagate lazy `array_record_matcher` priority delta up ancestor matchers and copy-on-write re-sort enclosing composite matchers (`mongory_matcher_resort_composite`) with atomic acquire/release publication.
13
+ - **CI**:
14
+ - Auto-create GitHub Release after gem push in `.github/workflows/build.yml`.
15
+
3
16
  ## [0.9.0] - 2026-11-17
4
17
 
5
18
  Aligns with mongory-spec `0.2.0` and `mongory-core` `v0.2.0`.
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
- # Mongory
2
- ### Let you query everywhere !
1
+ # Mongory (Ruby)
3
2
 
4
- This is a Mongo-like in-memory query DSL for Ruby.
3
+ **Cross-language, in-memory Mongo-style rule engine & query matcher with built-in Explain & Trace debugging** — optional C99 acceleration ([`mongory-core`](https://github.com/mongoryhq/mongory-core)), pure Ruby fallback, and cross-language parity via [`mongory-spec`](https://github.com/mongoryhq/mongory-spec).
5
4
 
6
- Mongory lets you filter and query in-memory collections using syntax and semantics similar to MongoDB. It is designed for expressive chaining, symbolic operators, and composable matchers.
5
+ **[Try the Interactive Playground & Visual Explain/Trace Debugger ↗](https://mongoryhq.github.io/mongory-central/)**
6
+
7
+ [![Mongory Playground & Visual Trace](https://mongoryhq.github.io/mongory-central/playground-trace.png)](https://mongoryhq.github.io/mongory-central/)
8
+
9
+ > **Zero database required:** Mongory evaluates MongoDB-style conditions (`$gte`, `$elemMatch`, `$every`, `$present`, `$regex`, etc.) directly against in-memory Ruby objects, hashes, and ActiveRecord relations.
10
+ > **Ecosystem:** [Interactive Playground](https://mongoryhq.github.io/mongory-central/) · [`mongory-go` (Go)](https://github.com/mongoryhq/mongory-go) · [`mongory-js` (TypeScript/JS)](https://github.com/mongoryhq/mongory-js) · [`mongory-core` (C99)](https://github.com/mongoryhq/mongory-core) · [`mongory-spec`](https://github.com/mongoryhq/mongory-spec)
7
11
 
8
12
  ## Table of Contents
9
13
 
@@ -55,6 +55,7 @@ mongory_matcher *mongory_matcher_base_new(mongory_memory_pool *pool, mongory_val
55
55
  matcher->trace_level = 0;
56
56
  matcher->extern_ctx = extern_ctx; // Set the external context.
57
57
  matcher->priority = 1.0; // Set the priority to 1.0.
58
+ matcher->parent = NULL; // Attached later when wrapped by a parent.
58
59
  return matcher;
59
60
  }
60
61
 
@@ -55,6 +55,7 @@ struct mongory_matcher {
55
55
  mongory_array *trace_stack; /**< The trace stack for this matcher. */
56
56
  int trace_level; /**< The trace level for this matcher. */
57
57
  double priority; /**< The priority for this matcher. */
58
+ mongory_matcher *parent; /**< Enclosing parent matcher for dynamic priority updates. */
58
59
  void *extern_ctx; /**< External context for the matcher. */
59
60
  };
60
61
 
@@ -8,6 +8,7 @@
8
8
  #include "external_matcher.h"
9
9
  #include "../foundations/config_private.h" // For mongory_matcher_build_func_get
10
10
  #include "../foundations/array_private.h" // For mongory_array_sort_by
11
+ #include "../foundations/memory_pool_private.h" // For atomic children load/store
11
12
  #include "../foundations/string_buffer.h" // For mongory_string_buffer_new
12
13
  #include "base_matcher.h" // For mongory_matcher_always_true_new, etc.
13
14
  #include "literal_matcher.h" // For mongory_matcher_field_new
@@ -26,6 +27,18 @@
26
27
  double mongory_matcher_calculate_priority(mongory_array *sub_matchers);
27
28
  mongory_array *mongory_matcher_sort_matchers(mongory_array *sub_matchers);
28
29
 
30
+ static inline void mongory_matcher_attach_children_parent(mongory_composite_matcher *parent, mongory_array *children) {
31
+ if (!parent || !children) {
32
+ return;
33
+ }
34
+ for (size_t i = 0; i < children->count; i++) {
35
+ mongory_matcher *child = (mongory_matcher *)children->get(children, i);
36
+ if (child != NULL) {
37
+ child->parent = (mongory_matcher *)parent;
38
+ }
39
+ }
40
+ }
41
+
29
42
  /**
30
43
  * @brief Allocates and initializes a `mongory_composite_matcher` structure.
31
44
  *
@@ -61,6 +74,7 @@ mongory_composite_matcher *mongory_matcher_composite_new(mongory_memory_pool *po
61
74
  composite->base.traverse = mongory_matcher_composite_traverse;
62
75
  composite->base.extern_ctx = extern_ctx;
63
76
  composite->base.priority = 2.0;
77
+ composite->base.parent = NULL;
64
78
  return composite;
65
79
  }
66
80
 
@@ -80,7 +94,7 @@ mongory_composite_matcher *mongory_matcher_composite_new(mongory_memory_pool *po
80
94
  // ============================================================================
81
95
  static inline bool mongory_matcher_and_match(mongory_matcher *matcher, mongory_value *value) {
82
96
  mongory_composite_matcher *composite = (mongory_composite_matcher *)matcher;
83
- mongory_array *children = composite->children;
97
+ mongory_array *children = mongory_atomic_load_ptr_acquire(&composite->children);
84
98
  int total = (int)children->count;
85
99
  for (int i = 0; i < total; i++) {
86
100
  mongory_matcher *child = (mongory_matcher *)children->get(children, i);
@@ -104,7 +118,7 @@ static inline bool mongory_matcher_and_match(mongory_matcher *matcher, mongory_v
104
118
  */
105
119
  bool mongory_matcher_or_match(mongory_matcher *matcher, mongory_value *value) {
106
120
  mongory_composite_matcher *composite = (mongory_composite_matcher *)matcher;
107
- mongory_array *children = composite->children;
121
+ mongory_array *children = mongory_atomic_load_ptr_acquire(&composite->children);
108
122
  int total = (int)children->count;
109
123
  for (int i = 0; i < total; i++) {
110
124
  mongory_matcher *child = (mongory_matcher *)children->get(children, i);
@@ -259,6 +273,7 @@ mongory_matcher *mongory_matcher_table_cond_new(mongory_memory_pool *pool, mongo
259
273
  if (final_matcher == NULL)
260
274
  return NULL;
261
275
  final_matcher->children = mongory_matcher_sort_matchers(sub_matchers);
276
+ mongory_matcher_attach_children_parent(final_matcher, final_matcher->children);
262
277
  final_matcher->base.match = mongory_matcher_and_match;
263
278
  final_matcher->base.original_match = mongory_matcher_and_match;
264
279
  final_matcher->base.sub_count = sub_matchers->count;
@@ -344,6 +359,7 @@ mongory_matcher *mongory_matcher_and_new(mongory_memory_pool *pool, mongory_valu
344
359
  if (final_matcher == NULL)
345
360
  return NULL;
346
361
  final_matcher->children = mongory_matcher_sort_matchers(sub_matchers);
362
+ mongory_matcher_attach_children_parent(final_matcher, final_matcher->children);
347
363
  final_matcher->base.match = mongory_matcher_and_match;
348
364
  final_matcher->base.original_match = mongory_matcher_and_match;
349
365
  final_matcher->base.sub_count = sub_matchers->count;
@@ -425,6 +441,7 @@ mongory_matcher *mongory_matcher_or_new(mongory_memory_pool *pool, mongory_value
425
441
  if (final_matcher == NULL)
426
442
  return NULL;
427
443
  final_matcher->children = mongory_matcher_sort_matchers(sub_matchers);
444
+ mongory_matcher_attach_children_parent(final_matcher, final_matcher->children);
428
445
  final_matcher->base.match = mongory_matcher_or_match;
429
446
  final_matcher->base.original_match = mongory_matcher_or_match;
430
447
  final_matcher->base.sub_count = sub_matchers->count;
@@ -487,6 +504,7 @@ mongory_matcher *mongory_matcher_elem_match_new(mongory_memory_pool *pool, mongo
487
504
  return NULL;
488
505
 
489
506
  composite->children = mongory_matcher_sort_matchers(sub_matchers);
507
+ mongory_matcher_attach_children_parent(composite, composite->children);
490
508
  composite->base.match = mongory_matcher_elem_match_match;
491
509
  composite->base.original_match = mongory_matcher_elem_match_match;
492
510
  composite->base.sub_count = sub_matchers->count;
@@ -546,6 +564,7 @@ mongory_matcher *mongory_matcher_every_new(mongory_memory_pool *pool, mongory_va
546
564
  return NULL;
547
565
 
548
566
  composite->children = mongory_matcher_sort_matchers(sub_matchers);
567
+ mongory_matcher_attach_children_parent(composite, composite->children);
549
568
  composite->base.match = mongory_matcher_every_match;
550
569
  composite->base.original_match = mongory_matcher_every_match;
551
570
  composite->base.sub_count = sub_matchers->count;
@@ -592,3 +611,17 @@ mongory_array *mongory_matcher_sort_matchers(mongory_array *sub_matchers) {
592
611
  temp_pool->free(temp_pool);
593
612
  return sorted_matchers;
594
613
  }
614
+
615
+ void mongory_matcher_resort_composite(mongory_composite_matcher *composite) {
616
+ if (!composite) {
617
+ return;
618
+ }
619
+ mongory_array *cur = mongory_atomic_load_ptr_acquire(&composite->children);
620
+ if (!cur || cur->count <= 1) {
621
+ return;
622
+ }
623
+ mongory_array *sorted = mongory_matcher_sort_matchers(cur);
624
+ if (sorted != NULL) {
625
+ mongory_atomic_store_ptr_release(&composite->children, sorted);
626
+ }
627
+ }
@@ -122,4 +122,10 @@ mongory_composite_matcher *mongory_matcher_composite_new(mongory_memory_pool *po
122
122
  */
123
123
  bool mongory_matcher_or_match(mongory_matcher *matcher, mongory_value *value);
124
124
 
125
+ /**
126
+ * @brief Re-sorts a composite matcher's children by updated priority using
127
+ * copy-on-write atomic publication safe for concurrent readers.
128
+ */
129
+ void mongory_matcher_resort_composite(mongory_composite_matcher *composite);
130
+
125
131
  #endif /* MONGORY_MATCHER_COMPOSITE_H */
@@ -125,6 +125,7 @@ mongory_matcher *mongory_matcher_regex_with_options_new(mongory_memory_pool *poo
125
125
  matcher->base.extern_ctx = extern_ctx;
126
126
  matcher->base.name = mongory_string_cpy(pool, "Regex");
127
127
  matcher->base.priority = 20.0;
128
+ matcher->base.parent = NULL;
128
129
  matcher->options = has_options ? mongory_string_cpy(pool, options->data.s) : NULL;
129
130
  return (mongory_matcher *)matcher;
130
131
  }
@@ -181,5 +182,6 @@ mongory_matcher *mongory_matcher_custom_new(mongory_memory_pool *pool, char *key
181
182
  matcher->base.extern_ctx = extern_ctx;
182
183
  matcher->external_matcher = context->external_matcher;
183
184
  matcher->base.priority = 20.0;
185
+ matcher->base.parent = NULL;
184
186
  return (mongory_matcher *)matcher;
185
187
  }
@@ -92,6 +92,16 @@ static inline bool mongory_matcher_literal_match(mongory_matcher *matcher, mongo
92
92
  mongory_matcher_enable_trace_at(arm, literal->base.trace_stack, literal->base.trace_level + 1);
93
93
  }
94
94
  if (arm != NULL) {
95
+ arm->parent = &literal->base;
96
+ double delta = (1.0 + arm->priority) - literal->base.priority;
97
+ if (delta != 0.0) {
98
+ for (mongory_matcher *cur = &literal->base; cur != NULL; cur = cur->parent) {
99
+ cur->priority += delta;
100
+ if (cur->traverse == mongory_matcher_composite_traverse) {
101
+ mongory_matcher_resort_composite((mongory_composite_matcher *)cur);
102
+ }
103
+ }
104
+ }
95
105
  mongory_atomic_store_ptr_release(&literal->array_record_matcher, arm);
96
106
  } else {
97
107
  mongory_propagate_build_error(build_pool, value);
@@ -260,6 +270,8 @@ mongory_matcher *mongory_matcher_field_new(mongory_memory_pool *pool, char *fiel
260
270
  return NULL;
261
271
  }
262
272
  field_m->literal.base.priority = 1.0 + field_m->literal.delegate_matcher->priority;
273
+ field_m->literal.base.parent = NULL;
274
+ field_m->literal.delegate_matcher->parent = (mongory_matcher *)field_m;
263
275
 
264
276
  return (mongory_matcher *)field_m;
265
277
  }
@@ -300,6 +312,8 @@ mongory_matcher *mongory_matcher_not_new(mongory_memory_pool *pool, mongory_valu
300
312
  literal->base.sub_count = 1;
301
313
  literal->base.extern_ctx = extern_ctx;
302
314
  literal->base.priority = 1.0 + literal->delegate_matcher->priority;
315
+ literal->base.parent = NULL;
316
+ literal->delegate_matcher->parent = (mongory_matcher *)literal;
303
317
  return (mongory_matcher *)literal;
304
318
  }
305
319
 
@@ -351,6 +365,8 @@ mongory_matcher *mongory_matcher_size_new(mongory_memory_pool *pool, mongory_val
351
365
  literal->base.sub_count = 1;
352
366
  literal->base.extern_ctx = extern_ctx;
353
367
  literal->base.priority = 1.0 + literal->delegate_matcher->priority;
368
+ literal->base.parent = NULL;
369
+ literal->delegate_matcher->parent = (mongory_matcher *)literal;
354
370
  return (mongory_matcher *)literal;
355
371
  }
356
372
 
@@ -2,6 +2,7 @@
2
2
  #define MONGORY_MATCHER_TRAVERSABLE_C
3
3
 
4
4
  #include "matcher_traversable.h"
5
+ #include "../foundations/memory_pool_private.h"
5
6
  #include "base_matcher.h"
6
7
  #include "composite_matcher.h"
7
8
  #include "literal_matcher.h"
@@ -19,7 +20,7 @@ bool mongory_matcher_composite_traverse(mongory_matcher *matcher, mongory_matche
19
20
  if (!mongory_matcher_leaf_traverse(matcher, ctx))
20
21
  return false;
21
22
  mongory_composite_matcher *composite = (mongory_composite_matcher *)matcher;
22
- mongory_array *children = composite->children;
23
+ mongory_array *children = mongory_atomic_load_ptr_acquire(&composite->children);
23
24
  int total = (int)children->count;
24
25
  mongory_matcher_traverse_context child_ctx = {
25
26
  .pool = ctx->pool,
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -60,6 +60,9 @@ module Mongory
60
60
  # @return [Context] the query context containing configuration and current record
61
61
  attr_reader :context
62
62
 
63
+ # @return [AbstractMatcher, nil] the enclosing matcher notified when priority changes
64
+ attr_accessor :parent
65
+
63
66
  # Returns a unique key representing this matcher instance.
64
67
  # Used for deduplication in multi-matchers.
65
68
  #
@@ -165,8 +168,33 @@ module Mongory
165
168
  20
166
169
  end
167
170
 
171
+ # Clears memoized match procs after a descendant changes priority or order.
172
+ #
173
+ # @return [void]
174
+ def invalidate_proc_cache!
175
+ @cached_proc = nil
176
+ remove_instance_variable(:@debug_proc) if instance_variable_defined?(:@debug_proc)
177
+ end
178
+
179
+ # Called by a child matcher after its priority increases dynamically.
180
+ #
181
+ # @return [void]
182
+ def on_child_priority_changed
183
+ notify_priority_changed
184
+ end
185
+
168
186
  private
169
187
 
188
+ def notify_priority_changed
189
+ invalidate_proc_cache!
190
+ @parent&.on_child_priority_changed
191
+ end
192
+
193
+ def attach_child(child)
194
+ child.parent = self if child.respond_to?(:parent=)
195
+ child
196
+ end
197
+
170
198
  # Returns a single-line string representing this matcher in the tree output.
171
199
  # Format: `<MatcherType>: <condition.inspect>`
172
200
  #
@@ -46,9 +46,11 @@ module Mongory
46
46
  def self.build_or_unwrap(*args, context: Context.new)
47
47
  matcher = new(*args, context: context)
48
48
  return matcher unless @enable_unwrap
49
+ return matcher unless matcher.matchers.count == 1
49
50
 
50
- matcher = matcher.matchers.first if matcher.matchers.count == 1
51
- matcher
51
+ unwrapped = matcher.matchers.first
52
+ unwrapped.parent = nil if unwrapped.respond_to?(:parent=)
53
+ unwrapped
52
54
  end
53
55
 
54
56
  # Recursively checks all submatchers for validity.
@@ -80,8 +82,32 @@ module Mongory
80
82
  1 + matchers.sum(&:priority)
81
83
  end
82
84
 
85
+ # Re-sorts active child matchers after a lazy submatcher increases priority
86
+ # and invalidates memoized procs up the tree.
87
+ #
88
+ # @return [void]
89
+ def on_child_priority_changed
90
+ resort_matchers!
91
+ super
92
+ end
93
+
83
94
  private
84
95
 
96
+ def sort_and_adopt(children)
97
+ children.each { |child| attach_child(child) }
98
+ stable_sort_by_priority(children)
99
+ end
100
+
101
+ def resort_matchers!
102
+ return unless instance_variable_defined?(:@matchers)
103
+
104
+ @matchers = stable_sort_by_priority(@matchers)
105
+ end
106
+
107
+ def stable_sort_by_priority(children)
108
+ children.each_with_index.sort_by { |child, idx| [child.priority, idx] }.map(&:first)
109
+ end
110
+
85
111
  # Recursively combines multiple matcher procs with AND logic.
86
112
  # This method optimizes the combination of multiple matchers by building
87
113
  # a balanced tree of AND operations.
@@ -47,9 +47,10 @@ module Mongory
47
47
  # @return [Array<AbstractMatcher>] A flattened, deduplicated list of matchers
48
48
  # @see AbstractMatcher#uniq_key
49
49
  define_instance_cache_method(:matchers) do
50
- @condition.flat_map do |condition|
50
+ children = @condition.flat_map do |condition|
51
51
  HashConditionMatcher.new(condition, context: @context).matchers
52
- end.uniq(&:uniq_key).sort_by(&:priority)
52
+ end.uniq(&:uniq_key)
53
+ sort_and_adopt(children)
53
54
  end
54
55
 
55
56
  # Ensures the condition is an array of hashes.
@@ -56,7 +56,7 @@ module Mongory
56
56
  else
57
57
  ElemMatchMatcher.build({ '$eq' => @condition }, context: @context)
58
58
  end
59
- result.sort_by(&:priority)
59
+ sort_and_adopt(result)
60
60
  end
61
61
 
62
62
  ELEM_MATCH_OPERATORS = %w($gt $gte $lt $lte $regex).freeze
@@ -46,11 +46,12 @@ module Mongory
46
46
  # @return [Array<AbstractMatcher>] List of matchers for each condition
47
47
  # @raise [TypeError] for an unknown operator or a `$options` without `$regex`
48
48
  define_instance_cache_method(:matchers) do
49
- @condition.map do |key, value|
49
+ children = @condition.map do |key, value|
50
50
  next if key == '$options' && @condition.key?('$regex')
51
51
 
52
52
  build_matcher(key, value)
53
- end.compact.sort_by(&:priority)
53
+ end.compact
54
+ sort_and_adopt(children)
54
55
  end
55
56
 
56
57
  def check_validity!
@@ -35,12 +35,16 @@ module Mongory
35
35
  #
36
36
  # @return [Proc] a Proc that performs the literal matching operation
37
37
  def raw_proc
38
- array_record_proc = nil
38
+ array_record_proc = @array_record_matcher&.to_proc
39
39
  dispatched_proc = dispatched_matcher.to_proc
40
40
 
41
41
  Proc.new do |record|
42
42
  if record.is_a?(Array)
43
- array_record_proc ||= array_record_matcher.to_proc
43
+ unless array_record_proc
44
+ built = !instance_variable_defined?(:@array_record_matcher)
45
+ array_record_proc = array_record_matcher.to_proc
46
+ notify_priority_changed if built
47
+ end
44
48
  array_record_proc.call(record)
45
49
  else
46
50
  dispatched_proc.call(record)
@@ -49,7 +53,7 @@ module Mongory
49
53
  end
50
54
 
51
55
  def priority
52
- 1 + dispatched_matcher.priority
56
+ 1 + (@array_record_matcher || dispatched_matcher).priority
53
57
  end
54
58
 
55
59
  # Selects and returns the appropriate matcher instance for a given literal condition.
@@ -73,19 +77,20 @@ module Mongory
73
77
  # @return [AbstractMatcher] the matcher used for non-array literal values
74
78
  # @!method dispatched_matcher
75
79
  define_matcher(:dispatched) do
76
- case @condition
77
- when Hash
78
- HashConditionMatcher.build(@condition, context: @context)
79
- when Regexp
80
- RegexMatcher.build(@condition, context: @context)
81
- when nil
82
- OrMatcher.build([
83
- { '$exists' => false },
84
- { '$eq' => nil }
85
- ], context: @context)
86
- else
87
- EqMatcher.build(@condition, context: @context)
88
- end
80
+ matcher = case @condition
81
+ when Hash
82
+ HashConditionMatcher.build(@condition, context: @context)
83
+ when Regexp
84
+ RegexMatcher.build(@condition, context: @context)
85
+ when nil
86
+ OrMatcher.build([
87
+ { '$exists' => false },
88
+ { '$eq' => nil }
89
+ ], context: @context)
90
+ else
91
+ EqMatcher.build(@condition, context: @context)
92
+ end
93
+ attach_child(matcher)
89
94
  end
90
95
 
91
96
  # Lazily defines the collection matcher for array records.
@@ -94,7 +99,7 @@ module Mongory
94
99
  # @return [ArrayRecordMatcher] the matcher used to match array-type records
95
100
  # @!method array_record_matcher
96
101
  define_matcher(:array_record) do
97
- ArrayRecordMatcher.build(@condition, context: @context)
102
+ attach_child(ArrayRecordMatcher.build(@condition, context: @context))
98
103
  end
99
104
 
100
105
  # Validates the nested condition matcher, if applicable.
@@ -43,9 +43,10 @@ module Mongory
43
43
  #
44
44
  # @return [Array<AbstractMatcher>] array of submatchers
45
45
  define_instance_cache_method(:matchers) do
46
- @condition.map do |condition|
46
+ children = @condition.map do |condition|
47
47
  HashConditionMatcher.build(condition, context: @context)
48
- end.sort_by(&:priority)
48
+ end
49
+ sort_and_adopt(children)
49
50
  end
50
51
 
51
52
  # Ensures the condition is an array of hashes.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mongory
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - koten0224
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-16 00:00:00.000000000 Z
11
+ date: 2026-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Mongo-like in-memory query DSL for Ruby
14
14
  email: