Skip to content
This repository has been archived by the owner on Jan 3, 2021. It is now read-only.

Add a save method to the _Model protocol #19

Merged
merged 1 commit into from
Feb 6, 2019
Merged

Conversation

Obbut
Copy link
Member

@Obbut Obbut commented Feb 5, 2019

This PR adds a save method to the _Model protocol. It also adds a default implementation of the method to the Model protocol.

Because the _Model protocol is not meant to be directly conformed to, this change can be considered as purely additive and non-breaking.

Motivation

The Model protocol has an associated type requirement (Identifier). There are cases where you want to perform a save operation on a Model, while the exact type is unknown. With this PR, you can:

let maybeAModel: Any = ...
if let model = maybeAModel as? _Model {
    model.save(to: context)
}

@Obbut Obbut requested a review from Joannis February 5, 2019 14:23
@Obbut Obbut merged commit 6e9dc27 into master/2.0 Feb 6, 2019
@Obbut Obbut deleted the feature/save-on-model branch February 6, 2019 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants