Commit 41e8118
Stop polluting Cacheable namespace with interceptor constants
Previously, each class that included Cacheable created a constant
on the Cacheable module (e.g. Cacheable::MyClassCacher) via
const_set. This polluted the namespace and leaked memory for
anonymous classes. Re-including Cacheable used remove_const which
left ghost modules in the MRO.
Now interceptor modules are stored as instance variables on the
including class (@_cacheable_interceptor). The module gets a
descriptive to_s/inspect for debugging without creating constants.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent f7f6cba commit 41e8118
3 files changed
Lines changed: 10 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 92 | | |
98 | | - | |
| 93 | + | |
99 | 94 | | |
100 | | - | |
| 95 | + | |
101 | 96 | | |
102 | 97 | | |
103 | 98 | | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
107 | | - | |
| 102 | + | |
108 | 103 | | |
109 | 104 | | |
110 | 105 | | |
| |||
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
129 | | - | |
| 124 | + | |
130 | 125 | | |
131 | 126 | | |
132 | 127 | | |
| |||
0 commit comments