From 9dd800a0f32aa26a6bcf76b09c2648afe9ab0018 Mon Sep 17 00:00:00 2001 From: Grady Zhuo Date: Sun, 23 Jun 2024 20:50:13 +0800 Subject: [PATCH] [Refactor] rename FluentInterfaceOptions to Builderable. --- .../EventStoreDB/utils/FluentInterface.swift | 33 ------------------- ...ntStoreOptions.swift => Builderable.swift} | 8 ++--- 2 files changed, 4 insertions(+), 37 deletions(-) delete mode 100644 Sources/EventStoreDB/utils/FluentInterface.swift rename Sources/GRPCEncapsulates/{EventStoreOptions.swift => Builderable.swift} (51%) diff --git a/Sources/EventStoreDB/utils/FluentInterface.swift b/Sources/EventStoreDB/utils/FluentInterface.swift deleted file mode 100644 index 060d458..0000000 --- a/Sources/EventStoreDB/utils/FluentInterface.swift +++ /dev/null @@ -1,33 +0,0 @@ -//// -//// FluentInterface.swift -//// -//// -//// Created by Grady Zhuo on 2023/12/27. -//// -// -// import Foundation -// -//// reference: https://www.appcoda.com.tw/fluent-interface/ -// @dynamicMemberLookup -// public struct FluentInterface { -// public let subject: Subject -// -// // 因為要動到 subject 的屬性,所以 keyPath 的型別必須是 WritableKeyPath -// // 回傳值是一個 Setter 方法 -// -// public subscript(dynamicMember keyPath: WritableKeyPath) -> ((Value) -> FluentInterface) { -// // 因為在要回傳的 Setter 方法裡不能更改 self,所以要把 subject 從 self 取出來用 -// var subject = self.subject -// -// // subject 實體的 Setter 方法 -// return { value in -// -// // 把 value 指派給 subject 的屬性 -// subject[keyPath: keyPath] = value -// -// // 回傳的型別是 FluentInterface 而不是 Subject -// // 因為現在的流暢界面是用 FluentInterface 型別來串,而不是 Subject 本身 -// return FluentInterface(subject: subject) -// } -// } -// } diff --git a/Sources/GRPCEncapsulates/EventStoreOptions.swift b/Sources/GRPCEncapsulates/Builderable.swift similarity index 51% rename from Sources/GRPCEncapsulates/EventStoreOptions.swift rename to Sources/GRPCEncapsulates/Builderable.swift index 6c7afdc..bd92a44 100644 --- a/Sources/GRPCEncapsulates/EventStoreOptions.swift +++ b/Sources/GRPCEncapsulates/Builderable.swift @@ -8,16 +8,16 @@ import Foundation import SwiftProtobuf -package protocol FluentInterfaceOptions: Sendable {} +package protocol Builderable: Sendable {} -extension FluentInterfaceOptions { - package func withCopy(handler: (_ options: inout Self) -> Void) -> Self { +extension Builderable { + package func withCopy(handler: (_ copied: inout Self) -> Void) -> Self { var copiedSelf = self handler(&copiedSelf) return copiedSelf } } -package protocol EventStoreOptions: GRPCBridge, FluentInterfaceOptions { +package protocol EventStoreOptions: GRPCBridge, Builderable { func build() -> UnderlyingMessage }