From 0d9299f900c8e6da4d61d5b5f6b61bf6a1d3f596 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 25 Mar 2020 14:21:49 +0900 Subject: [PATCH] WIP: docs --- Sources/Field.Relationship.swift | 1 - Sources/Field.Stored.swift | 7 ++----- Sources/Field.swift | 32 +++++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Sources/Field.Relationship.swift b/Sources/Field.Relationship.swift index 486b207..c99b07c 100644 --- a/Sources/Field.Relationship.swift +++ b/Sources/Field.Relationship.swift @@ -34,7 +34,6 @@ extension FieldContainer { // MARK: - Relationship @propertyWrapper -// @dynamicMemberLookup public struct Relationship: RelationshipKeyPathStringConvertible, FieldRelationshipProtocol { /** diff --git a/Sources/Field.Stored.swift b/Sources/Field.Stored.swift index 10e9663..99f73c3 100644 --- a/Sources/Field.Stored.swift +++ b/Sources/Field.Stored.swift @@ -40,11 +40,8 @@ extension FieldContainer { @Field.Stored("species") var species = "" - @Field.Virtual("pluralName", customGetter: Animal.pluralName(_:)) - var pluralName: String = "" - - @Field.Coded("color", coder: FieldCoders.Plist.self) - var color: UIColor? + @Field.Stored("nickname") + var nickname: String? } ``` - Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.Stored(...) var` syntax will be ignored. diff --git a/Sources/Field.swift b/Sources/Field.swift index 7ed8018..28f439e 100644 --- a/Sources/Field.swift +++ b/Sources/Field.swift @@ -32,9 +32,9 @@ import Foundation extension DynamicObject where Self: CoreStoreObject { /** - The containing type for value propertiess. `Field` properties support any type that conforms to `ImportableAttributeType`. + The containing type for value propertiess. ``` - class Animal: CoreStoreObject { + class Pet: CoreStoreObject { @Field.Stored("species") var species = "" @@ -42,10 +42,19 @@ extension DynamicObject where Self: CoreStoreObject { var nickname: String? @Field.Coded("color", coder: FieldCoders.Plist.self) - var color: UIColor? + var eyeColor: UIColor? + + @Field.Relationship("owner", inverse: \.$pets) + var owner: Person? + + @Field.Relationship("children") + var children: Array + + @Field.Relationship("parents", inverse: \.$children) + var parents: Set } ``` - - Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.*(...) var` syntax will be ignored. + - Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.*(...) var` syntax will result in undefined behavior. */ public typealias Field = FieldContainer } @@ -54,9 +63,9 @@ extension DynamicObject where Self: CoreStoreObject { // MARK: - FieldContainer /** - The containing type for value properties. Use the `DynamicObject.Field` typealias instead for shorter syntax. + The containing type for value properties. Use the `Field` typealias instead for shorter syntax. ``` - class Animal: CoreStoreObject { + class Pet: CoreStoreObject { @Field.Stored("species") var species = "" @@ -64,7 +73,16 @@ extension DynamicObject where Self: CoreStoreObject { var nickname: String? @Field.Coded("color", coder: FieldCoders.Plist.self) - var color: UIColor? + var eyeColor: UIColor? + + @Field.Relationship("owner", inverse: \.$pets) + var owner: Person? + + @Field.Relationship("children") + var children: Array + + @Field.Relationship("parents", inverse: \.$children) + var parents: Set } ``` */