mongo_mapper 0.17.0 → 0.18.1

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.
@@ -5,6 +5,50 @@ describe "Plugins" do
5
5
  Class.new { extend MongoMapper::Plugins }.plugins.should == []
6
6
  end
7
7
 
8
+ context "direct_descendants" do
9
+ def build_and_forget(count)
10
+ count.times.map { yield.object_id }
11
+ end
12
+
13
+ def live_descendant_ids(mod, ids)
14
+ mod.direct_descendants.map(&:object_id) & ids
15
+ end
16
+
17
+ # Ruby 3.1 and 3.2 keep a fixed-size global method call cache (1023 slots)
18
+ # that the GC treats as a root. It pins the most recently defined model
19
+ # classes through their singleton classes, so they can't be collected even
20
+ # though nothing else references them. Defining singleton methods on lots of
21
+ # throwaway classes evicts those entries. Ruby 3.3+ no longer marks the
22
+ # cache, so this is skipped there.
23
+ def flush_global_method_cache
24
+ return unless RUBY_ENGINE == "ruby" && RUBY_VERSION >= "3.1" && RUBY_VERSION < "3.3"
25
+
26
+ 10_000.times { Class.new.define_singleton_method(:flush) {} }
27
+ end
28
+
29
+ [
30
+ ["Document", MongoMapper::Document, lambda { Doc() }],
31
+ ["EmbeddedDocument", MongoMapper::EmbeddedDocument, lambda { EDoc() }],
32
+ ].each do |label, mod, builder|
33
+ it "should not retain #{label} models that are no longer referenced" do
34
+ skip "GC is not deterministic on JRuby" if RUBY_ENGINE == "jruby"
35
+
36
+ ids = build_and_forget(20) { builder.call }
37
+
38
+ flush_global_method_cache
39
+
40
+ 3.times { GC.start(full_mark: true, immediate_sweep: true) }
41
+
42
+ live_descendant_ids(mod, ids).size.should < 20
43
+ end
44
+ end
45
+
46
+ it "should track models that are still referenced" do
47
+ model = Doc()
48
+ MongoMapper::Document.direct_descendants.should include(model)
49
+ end
50
+ end
51
+
8
52
  context "a plugin" do
9
53
  module MyConcern
10
54
  extend ActiveSupport::Concern
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-12-10 00:00:00.000000000 Z
13
+ date: 2026-11-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mongo
@@ -184,6 +184,7 @@ files:
184
184
  - lib/mongo_mapper/plugins/embedded_callbacks.rb
185
185
  - lib/mongo_mapper/plugins/embedded_document.rb
186
186
  - lib/mongo_mapper/plugins/equality.rb
187
+ - lib/mongo_mapper/plugins/global_id.rb
187
188
  - lib/mongo_mapper/plugins/identity_map.rb
188
189
  - lib/mongo_mapper/plugins/indexes.rb
189
190
  - lib/mongo_mapper/plugins/inspect.rb
@@ -220,6 +221,9 @@ files:
220
221
  - lib/rails/generators/mongo_mapper/config/templates/mongo.yml
221
222
  - lib/rails/generators/mongo_mapper/model/model_generator.rb
222
223
  - lib/rails/generators/mongo_mapper/model/templates/model.rb
224
+ - spec/config/alias.yml
225
+ - spec/config/erb.yml
226
+ - spec/config/simple.yml
223
227
  - spec/examples.txt
224
228
  - spec/functional/accessible_spec.rb
225
229
  - spec/functional/associations/belongs_to_polymorphic_proxy_spec.rb
@@ -248,6 +252,7 @@ files:
248
252
  - spec/functional/embedded_document_spec.rb
249
253
  - spec/functional/equality_spec.rb
250
254
  - spec/functional/extensions_spec.rb
255
+ - spec/functional/global_id_spec.rb
251
256
  - spec/functional/identity_map_spec.rb
252
257
  - spec/functional/indexes_spec.rb
253
258
  - spec/functional/keys_spec.rb
@@ -309,9 +314,9 @@ licenses:
309
314
  - MIT
310
315
  metadata:
311
316
  bug_tracker_uri: https://github.com/mongomapper/mongomapper/issues
312
- changelog_uri: https://github.com/mongomapper/mongomapper/releases/tag/v0.17.0
313
- documentation_uri: https://www.rubydoc.info/gems/mongomapper/0.17.0
314
- source_code_uri: https://github.com/mongomapper/mongomapper/tree/v0.17.0
317
+ changelog_uri: https://github.com/mongomapper/mongomapper/releases/tag/v0.18.1
318
+ documentation_uri: https://www.rubydoc.info/gems/mongomapper/0.18.1
319
+ source_code_uri: https://github.com/mongomapper/mongomapper/tree/v0.18.1
315
320
  post_install_message:
316
321
  rdoc_options: []
317
322
  require_paths:
@@ -327,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
332
  - !ruby/object:Gem::Version
328
333
  version: '0'
329
334
  requirements: []
330
- rubygems_version: 3.5.22
335
+ rubygems_version: 3.5.9
331
336
  signing_key:
332
337
  specification_version: 4
333
338
  summary: A Ruby Object Mapper for Mongo