From 7eccf812217a8ab6c498346303de2bcd1d3017bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Tue, 8 Sep 2015 08:13:49 +0200 Subject: [PATCH] DESIGN.md --- DESIGN.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DESIGN.md b/DESIGN.md index f9b29c3b1..2e667b6be 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -33,6 +33,19 @@ More than caveats or defects, there are a few glitches, or surprises in the GRDB ... } } + + // A RowModel that deletes an external resource after being deleted from + // the database: + class C : RowModel { + public func delete(db: Database) throws -> DeletionResult { + switch super.delete(db) { + case .RowDeleted: + try NSFileManager.defaultManager().removeItemAtPath(...) + case .NoRowDeleted: + break + } + } + } ``` A second reason: the `databaseEdited` flag, which is true when a RowModel has unsaved changes, is easily provided by the base class RowModel. RowModel can manage its internal state *accross method calls*. Protocols could not provide this service without extra complexity.