Skip to content

[BAC-1267] Compile the JSON attribute assigner per exact class - #23

Merged
HolyWalley merged 2 commits into
masterfrom
feature/BAC-1267
Jul 15, 2026
Merged

[BAC-1267] Compile the JSON attribute assigner per exact class#23
HolyWalley merged 2 commits into
masterfrom
feature/BAC-1267

Conversation

@HolyWalley

@HolyWalley HolyWalley commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Parsers::JSON generated assign_attributes_from_json via method_missing, defining it on the class of the first instance that parsed JSON. Subclasses inherited that compiled method, method_missing never fired for them, and subclass-only attributes were silently dropped for the lifetime of the process:

Receptionist.from_json({...})                            # compiles assigner on Receptionist
BusyFallback.from_json({'transcript' => 'T'}).transcript # => nil (BusyFallback < Receptionist)

In karen this loses BusyFallback#transcript on every Redis round-trip once a receptionist config has been parsed (any live process), and makes specs order-dependent.

The assigner is now compiled once per exact class — memoized in a class-level ivar, which is not inherited — and dispatched through a stable module method, so a superclass's compiled assigner can never shadow subclass attributes.

Also bumps nokogiri in the dev lockfile (1.16.6 no longer builds on current macOS).

image

@HolyWalley
HolyWalley requested review from taleh007 and yard July 6, 2026 17:56
@HolyWalley
HolyWalley merged commit 41e5989 into master Jul 15, 2026
1 check passed
@HolyWalley
HolyWalley deleted the feature/BAC-1267 branch July 15, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants