From d8d030286de3ad138465735979c5f10f71e6bf9f Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Thu, 6 Dec 2018 18:12:56 -0800 Subject: [PATCH] Add a little bit of code doc --- Sources/JSONAPI/Resource/Attribute.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Sources/JSONAPI/Resource/Attribute.swift b/Sources/JSONAPI/Resource/Attribute.swift index e9cd99c..40d1eec 100644 --- a/Sources/JSONAPI/Resource/Attribute.swift +++ b/Sources/JSONAPI/Resource/Attribute.swift @@ -8,6 +8,8 @@ public protocol AttributeType: Codable { } +// MARK: TransformedAttribute +/// A TransformedAttribute takes a Codable type and attempts to turn it into another type. public struct TransformedAttribute: AttributeType where Transformer.From == RawValue { private let rawValue: RawValue @@ -19,6 +21,15 @@ public struct TransformedAttribute = TransformedAttribute where RawValue == Validator.From + +// MARK: Attribute +/// An Attribute simply represents a type that can be encoded and decoded. +public typealias Attribute = TransformedAttribute> + extension TransformedAttribute where Transformer: ReversibleTransformer { public init(transformedValue: Transformer.To) throws { self.value = transformedValue @@ -43,10 +54,6 @@ extension TransformedAttribute where Transformer == IdentityTransformer = TransformedAttribute where RawValue == Validator.From - -public typealias Attribute = TransformedAttribute> - // MARK: - Codable extension TransformedAttribute { public init(from decoder: Decoder) throws {