Skip to content

Commit

Permalink
Merge pull request #3 from venmo/publicCustomFieldProtocols
Browse files Browse the repository at this point in the history
Updated CustomFields/MutableCustomFields Protocols
  • Loading branch information
dgallagher-venmo authored Jun 5, 2018
2 parents 830acf3 + 1a56a92 commit dd173e8
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Example/Cartfile.private
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "venmo/QuizTrain" ~> 1.1.0
github "venmo/QuizTrain" ~> 1.1.1
2 changes: 1 addition & 1 deletion Example/Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "venmo/QuizTrain" "v1.1.0"
github "venmo/QuizTrain" "v1.1.1"
2 changes: 1 addition & 1 deletion QuizTrain/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 1 addition & 8 deletions QuizTrain/Misc/Containment/Protocols/CustomFields.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/*
Provides read-only CustomField support.
*/
protocol CustomFields {
public protocol CustomFields {
var customFields: JSONDictionary { get }
var customFieldsContainer: CustomFieldsContainer { get }
}

extension CustomFields {
public var customFields: JSONDictionary {
return self.customFieldsContainer.customFields
}
}
14 changes: 1 addition & 13 deletions QuizTrain/Misc/Containment/Protocols/MutableCustomFields.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
Provides read-write CustomField support.
*/
protocol MutableCustomFields: CustomFields {
public protocol MutableCustomFields: CustomFields {
var customFields: JSONDictionary { get set }
var customFieldsContainer: CustomFieldsContainer { get set }
}

extension MutableCustomFields {
public var customFields: JSONDictionary {
get {
return self.customFieldsContainer.customFields
}
set {
customFieldsContainer.customFields = newValue
}
}
}
4 changes: 4 additions & 0 deletions QuizTrain/Models/Case.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public struct Case: Identifiable, MutableCustomFields, Equatable {
public let updatedBy: User.Id
public let updatedOn: Date
var customFieldsContainer: CustomFieldsContainer
public var customFields: JSONDictionary {
get { return self.customFieldsContainer.customFields }
set { customFieldsContainer.customFields = newValue }
}
}

// MARK: - Foward Relationships (ObjectAPI)
Expand Down
3 changes: 3 additions & 0 deletions QuizTrain/Models/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public struct Result: CustomFields, Identifiable, Equatable {
public let testId: Test.Id
public let version: String?
let customFieldsContainer: CustomFieldsContainer
public var customFields: JSONDictionary {
return self.customFieldsContainer.customFields
}
}

// MARK: - Foward Relationships (ObjectAPI)
Expand Down
3 changes: 3 additions & 0 deletions QuizTrain/Models/Test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public struct Test: CustomFields, Identifiable, Equatable {
public let title: String
public let typeId: CaseType.Id
let customFieldsContainer: CustomFieldsContainer
public var customFields: JSONDictionary {
return self.customFieldsContainer.customFields
}
}

// MARK: - Foward Relationships (ObjectAPI)
Expand Down
4 changes: 4 additions & 0 deletions QuizTrain/Network/Models/Add/NewCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public struct NewCase: MutableCustomFields, Equatable {
public var title: String
public var typeId: CaseType.Id?
var customFieldsContainer = CustomFieldsContainer.empty()
public var customFields: JSONDictionary {
get { return self.customFieldsContainer.customFields }
set { customFieldsContainer.customFields = newValue }
}

// MARK: Init

Expand Down
4 changes: 4 additions & 0 deletions QuizTrain/Network/Models/Add/NewCaseResults.Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ extension NewCaseResults {
public var statusId: Status.Id?
public var version: String?
var customFieldsContainer = CustomFieldsContainer.empty()
public var customFields: JSONDictionary {
get { return self.customFieldsContainer.customFields }
set { customFieldsContainer.customFields = newValue }
}

// MARK: Init

Expand Down
4 changes: 4 additions & 0 deletions QuizTrain/Network/Models/Add/NewResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public struct NewResult: MutableCustomFields, Equatable {
public var statusId: Status.Id?
public var version: String?
var customFieldsContainer = CustomFieldsContainer.empty()
public var customFields: JSONDictionary {
get { return self.customFieldsContainer.customFields }
set { customFieldsContainer.customFields = newValue }
}

// MARK: Init

Expand Down
4 changes: 4 additions & 0 deletions QuizTrain/Network/Models/Add/NewTestResults.Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ extension NewTestResults {
public var testId: Test.Id
public var version: String?
var customFieldsContainer = CustomFieldsContainer.empty()
public var customFields: JSONDictionary {
get { return self.customFieldsContainer.customFields }
set { customFieldsContainer.customFields = newValue }
}

// MARK: Init

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ QuizTrain is open source software released under the MIT License. See the [LICEN

[Carthage](https://github.com/Carthage/Carthage) is the recommended way to install QuizTrain. Add the following to your `Cartfile` or `Cartfile.private` file:

github "venmo/QuizTrain" ~> 1.1.0
github "venmo/QuizTrain" ~> 1.1.1

See [Adding frameworks to an application](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) for further instructions. Once complete `import QuizTrain` in any Swift files you wish to use QuizTrain in.

Expand Down

0 comments on commit dd173e8

Please sign in to comment.