Commit 9a952e6
committed
Drop the setter methods cache in favour of respond_to? (see #472)
The cache was not being updated when new attributes were added,
causing very strange behaviour. Any previously unseen attributes
passed to new with send_only_modified_attributes enabled would be
missing from the request parameters. This is because change tracking
is only effective for setter methods.
Updating the cache turned out to be more expensive than not having a
cache at all. Using respond_to? would be fastest but this breaks
things as respond_to_missing? returns true for any assignment method.
If method(:foo=).source_location returns nil then this may indicate
that the method is missing but this is also true for methods in native
code.
A faster and more reliable approach is using a fiber-local variable to
make respond_to_missing? return false while doing these checks. It's a
tad ugly but it's the best I can come up with.1 parent c319c63 commit 9a952e6
2 files changed
+23
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
202 | 212 | | |
203 | 213 | | |
204 | 214 | | |
205 | | - | |
206 | 215 | | |
207 | 216 | | |
208 | | - | |
| 217 | + | |
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
| |||
279 | 288 | | |
280 | 289 | | |
281 | 290 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
244 | 256 | | |
245 | 257 | | |
246 | 258 | | |
| |||
0 commit comments