activerecord-minimizer 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce54c61288bef93e5fb13a4f7b040549145511a46fa548b110565f7d9df146b6
4
- data.tar.gz: c9884dbd4f7c17218a23af522b93a9eef4d1f4144fff706cb09a76aa6ec4f7d5
3
+ metadata.gz: 4d267d90b4e0fb5fa138099d607c877642be888d811836e9a01ba5d902805f62
4
+ data.tar.gz: 0b5835ae5a2ed8290e2a1cfbce79be67e5a5a088339aba4531c38679f8bbe560
5
5
  SHA512:
6
- metadata.gz: e6745aa3893a7742b4002879166b7d2f547789a1382aa982bded4ee5398ea7955601bdee59e17695281c1f20006a129b9733ac054787ad68446550f7c37e6e1f
7
- data.tar.gz: 1d2db1e229d5b09b45e41751dbbac7869a3581878db7286adaea75245ef565d9da6f17b2519e600a75b5daf64cb2275e89fdf7515029e089feecaca5d89fed54
6
+ metadata.gz: 225301a99201d5b86bc759bd0aed0fb2b52ee410036ca844be740a013036639c94e9e58ffb71aca19aae5c17a364ba35e634500053a68b9f6b718838534bd2b9
7
+ data.tar.gz: ca8f655b05effb30eeaa8558463467ea42e96ddd0694842d90b18c170419ed7137791c83b98c4050665e34aeefcbb8272bda170fd9fde4ce7b96cc3fc2c08a1d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 (2026-10-18)
4
+
5
+ - Small records work on Rails main, whose attribute sets take a `default_keys` argument and get a fresh `{}` from Rails; the association cache Rails main leaves `nil` until used is left alone.
6
+ - CI also runs the tests on Rails 8.0 and a pinned commit of main.
7
+
3
8
  ## 0.1.0 (2026-10-18)
4
9
 
5
10
  First release.
data/README.md CHANGED
@@ -123,7 +123,7 @@ Rails 8.1, Ruby 4.0, M-series Mac. `bench/calls.rb`, ns per call:
123
123
 
124
124
  (Measured with the class guard; calls on known receivers skip it.)
125
125
 
126
- On golf-buddy (191 models, 2009 columns):
126
+ On [Japan Voyage](https://japanvoyage.jp) (191 models, 2009 columns):
127
127
 
128
128
  * Generated attribute methods at boot: 44,835 → about 4,500. Memory used by
129
129
  `define_attribute_methods`: 16.4 → about 6 MB; time 374 → about 225 ms.
@@ -31,8 +31,12 @@ module ArMinimizer
31
31
  end
32
32
 
33
33
  module AttributeSet
34
- def initialize(values, types, additional_types, default_attributes, attributes = nil)
35
- super(values, types, additional_types, default_attributes, attributes || (SmallRecords.enabled? ? EMPTY : {}))
34
+ # Rails 8.0/8.1 pass no attributes for a new set; main passes a fresh
35
+ # {} (and default_keys after it). Either way, an empty Hash only this
36
+ # set would own becomes the shared one.
37
+ def initialize(values, types, additional_types, default_attributes, attributes = nil, *rest)
38
+ attributes = EMPTY if SmallRecords.enabled? && (attributes.nil? || (attributes.empty? && !attributes.frozen?))
39
+ super(values, types, additional_types, default_attributes, attributes || {}, *rest)
36
40
  end
37
41
 
38
42
  def []=(name, value)
@@ -76,16 +80,18 @@ module ArMinimizer
76
80
  end
77
81
 
78
82
  module Associations
83
+ # Only a Hash Rails allocated is replaced: Rails main leaves the cache
84
+ # nil until an association is used.
79
85
  def initialize_dup(*)
80
86
  super
81
- @association_cache = EMPTY if SmallRecords.enabled?
87
+ @association_cache = EMPTY if SmallRecords.enabled? && @association_cache
82
88
  end
83
89
 
84
90
  private
85
91
 
86
92
  def init_internals
87
93
  super
88
- @association_cache = EMPTY if SmallRecords.enabled? # Rails' {} is dropped right away
94
+ @association_cache = EMPTY if SmallRecords.enabled? && @association_cache # Rails' {} is dropped right away
89
95
  end
90
96
 
91
97
  def association_instance_set(name, association)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArMinimizer
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-minimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen