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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/ar_minimizer/small_records.rb +10 -4
- data/lib/ar_minimizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d267d90b4e0fb5fa138099d607c877642be888d811836e9a01ba5d902805f62
|
|
4
|
+
data.tar.gz: 0b5835ae5a2ed8290e2a1cfbce79be67e5a5a088339aba4531c38679f8bbe560
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
-
|
|
35
|
-
|
|
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)
|
data/lib/ar_minimizer/version.rb
CHANGED