From 9a0bba8d070aa7fee680fa477ab16070d6ff1cd9 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Tue, 6 Aug 2019 09:12:02 -0700 Subject: [PATCH] Rename AppendableResourceBody to Appendable. It is used in conjunction with ResourceBody but does not conform to it anymore. --- Sources/JSONAPI/Document/Document.swift | 4 ++-- Sources/JSONAPI/Document/ResourceBody.swift | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/JSONAPI/Document/Document.swift b/Sources/JSONAPI/Document/Document.swift index 4034969..caad138 100644 --- a/Sources/JSONAPI/Document/Document.swift +++ b/Sources/JSONAPI/Document/Document.swift @@ -203,7 +203,7 @@ extension Document where IncludeType == NoIncludes, MetaType == NoMetadata, Link } */ -extension Document.Body.Data where PrimaryResourceBody: AppendableResourceBody { +extension Document.Body.Data where PrimaryResourceBody: Appendable { public func merging(_ other: Document.Body.Data, combiningMetaWith metaMerge: (MetaType, MetaType) -> MetaType, combiningLinksWith linksMerge: (LinksType, LinksType) -> LinksType) -> Document.Body.Data { @@ -214,7 +214,7 @@ extension Document.Body.Data where PrimaryResourceBody: AppendableResourceBody { } } -extension Document.Body.Data where PrimaryResourceBody: AppendableResourceBody, MetaType == NoMetadata, LinksType == NoLinks { +extension Document.Body.Data where PrimaryResourceBody: Appendable, MetaType == NoMetadata, LinksType == NoLinks { public func merging(_ other: Document.Body.Data) -> Document.Body.Data { return merging(other, combiningMetaWith: { _, _ in .none }, diff --git a/Sources/JSONAPI/Document/ResourceBody.swift b/Sources/JSONAPI/Document/ResourceBody.swift index 2eb1bb4..4dbac87 100644 --- a/Sources/JSONAPI/Document/ResourceBody.swift +++ b/Sources/JSONAPI/Document/ResourceBody.swift @@ -40,11 +40,11 @@ public protocol ResourceBody: Decodable, EncodableResourceBody {} /// A `ResourceBody` that has the ability to take on more primary /// resources by appending another similarly typed `ResourceBody`. -public protocol AppendableResourceBody { +public protocol Appendable { func appending(_ other: Self) -> Self } -public func +(_ left: R, right: R) -> R { +public func +(_ left: R, right: R) -> R { return left.appending(right) } @@ -56,7 +56,7 @@ public struct SingleResourceBody: EncodableResourceBody, AppendableResourceBody { +public struct ManyResourceBody: EncodableResourceBody, Appendable { public let values: [Entity] public init(resourceObjects: [Entity]) {