Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Persistence with attributeModifier Member #9

Merged
merged 5 commits into from
May 13, 2024

Conversation

mgacy
Copy link
Collaborator

@mgacy mgacy commented May 9, 2024

Previously, the live implementation of PersistenceFactory was created with a closure to support adding extra attributes (like a timestamp) to persisted values. This made it difficult to test that those values were actually added since the attribute addition was coupled with the use of DynamoDB to persist entities.

This fixes that by moving that closure to Persistence so that it can be tested independently of the logic used to actually persist values (via the put attribute) and revisions it more generally as a closure to modify persisted values. It also adds a member to create a Persistence instance that adds a timestamp to all persisted entities and a test for it.

/// - timestampProvider: A timestamp provider.
/// - put: A closure to persist item attributes.
/// - Returns: A `Persistence` instance.
static func addingTimestamp(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first considered an initializer, but this struck me as a little more explicit (though I don't love the name)

@mgacy mgacy requested a review from jagreenwood May 10, 2024 17:17
@mgacy mgacy merged commit e0a4d3b into main May 13, 2024
1 check passed
@mgacy mgacy deleted the refactor/attribute-modifier branch May 13, 2024 19:45
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