Merge pull request #47 from mattpolzin/feature/document-improvements

Feature/document improvements
This commit is contained in:
Mathew Polzin
2019-11-05 22:38:42 -08:00
committed by GitHub
3 changed files with 244 additions and 169 deletions
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -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 Appendable {
public protocol ResourceBodyAppendable {
func appending(_ other: Self) -> Self
}
public func +<R: Appendable>(_ left: R, right: R) -> R {
public func +<R: ResourceBodyAppendable>(_ left: R, right: R) -> R {
return left.appending(right)
}
@@ -60,7 +60,7 @@ public struct SingleResourceBody<Entity: JSONAPI.OptionalEncodablePrimaryResourc
}
/// A type allowing for a document body containing 0 or more primary resources.
public struct ManyResourceBody<Entity: JSONAPI.EncodablePrimaryResource>: EncodableResourceBody, Appendable {
public struct ManyResourceBody<Entity: JSONAPI.EncodablePrimaryResource>: EncodableResourceBody, ResourceBodyAppendable {
public let values: [Entity]
public init(resourceObjects: [Entity]) {
@@ -12,7 +12,7 @@ import Poly
class DocumentTests: XCTestCase {
func test_genericDocFunc() {
func test<Doc: JSONAPIDocument>(_ doc: Doc) {
func test<Doc: CodableJSONAPIDocument>(_ doc: Doc) {
let _ = encoded(value: doc)
XCTAssert(Doc.PrimaryResourceBody.self == NoResourceBody.self)