mirror of
https://github.com/encounter/JSONAPI.git
synced 2026-03-30 11:18:38 -07:00
small rename
This commit is contained in:
+5
-5
@@ -1,11 +1,11 @@
|
||||
//
|
||||
// SparseField.swift
|
||||
// SparseFieldset.swift
|
||||
//
|
||||
//
|
||||
// Created by Mathew Polzin on 8/4/19.
|
||||
//
|
||||
|
||||
public struct SparseField<
|
||||
public struct SparseFieldset<
|
||||
Description: JSONAPI.ResourceObjectDescription,
|
||||
MetaType: JSONAPI.Meta,
|
||||
LinksType: JSONAPI.Links,
|
||||
@@ -33,8 +33,8 @@ public struct SparseField<
|
||||
public extension ResourceObject where Description.Attributes: SparsableAttributes {
|
||||
|
||||
/// Get a Sparse Fieldset of this `ResourceObject` that can be encoded
|
||||
/// as a `PrimaryResource`.
|
||||
func sparse(with fields: [Description.Attributes.CodingKeys]) -> SparseField<Description, MetaType, LinksType, EntityRawIdType> {
|
||||
return SparseField(self, fields: fields)
|
||||
/// as a `SparsePrimaryResource`.
|
||||
func sparse(with fields: [Description.Attributes.CodingKeys]) -> SparseFieldset<Description, MetaType, LinksType, EntityRawIdType> {
|
||||
return SparseFieldset(self, fields: fields)
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// SparseFieldEncodableTests.swift
|
||||
// SparseFieldsetTests.swift
|
||||
//
|
||||
//
|
||||
// Created by Mathew Polzin on 8/4/19.
|
||||
@@ -13,7 +13,7 @@ import JSONAPITesting
|
||||
class SparseFieldEncoderTests: XCTestCase {
|
||||
func test_FullEncode() {
|
||||
let jsonEncoder = JSONEncoder()
|
||||
let sparseWithEverything = SparseField(testEverythingObject, fields: EverythingTest.Attributes.CodingKeys.allCases)
|
||||
let sparseWithEverything = SparseFieldset(testEverythingObject, fields: EverythingTest.Attributes.CodingKeys.allCases)
|
||||
|
||||
let encoded = try! jsonEncoder.encode(sparseWithEverything)
|
||||
|
||||
@@ -30,7 +30,7 @@ class SparseFieldEncoderTests: XCTestCase {
|
||||
XCTAssertEqual(type, EverythingTest.jsonType)
|
||||
XCTAssertNil(relationships)
|
||||
|
||||
XCTAssertEqual(attributesDict?.count, 9) // note not 10 because one value is omitted
|
||||
XCTAssertEqual(attributesDict?.count, 9) // note not 10 because one value is omitted intentionally at initialization
|
||||
XCTAssertEqual(attributesDict?["bool"] as? Bool,
|
||||
testEverythingObject[\.bool])
|
||||
XCTAssertEqual(attributesDict?["int"] as? Int,
|
||||
@@ -52,7 +52,7 @@ class SparseFieldEncoderTests: XCTestCase {
|
||||
|
||||
func test_PartialEncode() {
|
||||
let jsonEncoder = JSONEncoder()
|
||||
let sparseObject = SparseField(testEverythingObject, fields: [.string, .bool, .array])
|
||||
let sparseObject = SparseFieldset(testEverythingObject, fields: [.string, .bool, .array])
|
||||
|
||||
let encoded = try! jsonEncoder.encode(sparseObject)
|
||||
|
||||
Reference in New Issue
Block a user