Conversation
ngan
reviewed
May 5, 2026
| end | ||
|
|
||
| def save(parent_data: nil) | ||
| generate_statements(@captured_models + (parent_data ? parent_data.keys : [])) |
Collaborator
There was a problem hiding this comment.
Suggested change
| generate_statements(@captured_models + (parent_data ? parent_data.keys : [])) | |
| @captured_models.merge(parent_data.keys) if parent_data | |
| generate_statements(@captured_models) |
Contributor
Author
There was a problem hiding this comment.
Eh, merge will mutate and it feels weird mutating the instance variable with provided args. Technically you could call this multiple times with different parent_data, and I wouldn't expect the first call to leak into the second.
I can update this in a similar way to be more readable though.
ngan
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FixtureKit currently only supports saving and loading fixture data from SQL (via ActiveRecord). As we look to support other data sources — for example, Redis or other non-SQL stores — we need an abstraction that allows different persistence strategies to plug in alongside the existing SQL behavior.
This PR introduces that abstraction with a
Coderbase class and extracts the existing SQL logic intoActiveRecordCoderas the first step.What changed
FixtureKit::Coder, a base class that defines the coder interface:observe— wraps fixture evaluation, allowing a coder to subscribe to writes as they happen (no-op by default)save— encodes captured data into a persistable formmount— decodes and restores previously saved dataFixtureKit::ActiveRecordCoder < Coder, which contains all SQL-specific logic previously spread acrossCacheandSqlSubscriber(now deleted)Cachedelegates toActiveRecordCoderand is otherwise unaware of SQL detailsspec/unit/coders/active_record_coder_spec.rbwith focused unit tests for the coderWhat's next
Follow-up PR(s) will:
🤖 Generated with Claude Code