Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down Expand Up @@ -80,8 +80,8 @@ struct GameData: ParseObject {
var bytes: ParseBytes?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if shouldRestoreKey(\.polygon,
original: object) {
updated.polygon = object.polygon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ struct GameScore: ParseObject {
var name: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct User: ParseUser {
var customKey: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.customKey,
original: object) {
updated.customKey = object.customKey
Expand All @@ -55,8 +55,8 @@ struct Role<RoleUser: ParseUser>: ParseRole {
var name: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.name,
original: object) {
updated.name = object.name
Expand All @@ -78,8 +78,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ struct GameScore: ParseObject {
var name: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct GameScore: ParseObject {
var myFiles: [ParseFile]?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct GameScore: ParseObject {
var name: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct GameScore: ParseObject {
var name: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct GameScore: ParseObject {
var isHighest: Bool?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ struct User: ParseUser {
var customKey: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.customKey,
original: object) {
updated.customKey = object.customKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct User: ParseUser {
var allScores: [GameScore]?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.customKey,
original: object) {
updated.customKey = object.customKey
Expand Down Expand Up @@ -81,8 +81,8 @@ struct GameScore: ParseObject {
var points: Int? = 0

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down Expand Up @@ -244,7 +244,7 @@ User.anonymous.login { result in
}

//: Convert the anonymous user to a real new user.
var currentUser2 = User.current?.mergeable
var currentUser2 = User.current
currentUser2?.username = "bye"
currentUser2?.password = "world"
currentUser2?.signup { result in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ struct Installation: ParseInstallation {
var customKey: String?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.customKey,
original: object) {
updated.customKey = object.customKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct GameScore: ParseObject {
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct Book: ParseObject, ParseQueryScorable {
var relatedBook: Pointer<Book>?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.title,
original: object) {
updated.title = object.title
Expand Down Expand Up @@ -65,8 +65,8 @@ struct Author: ParseObject {
var otherBooks: [Book]?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.name,
original: object) {
updated.name = object.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct GameScore: ParseObject {
var myData: ParseFile?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/API/API+Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ internal extension API.Command {
original.hasSameObjectId(as: object) else {
return object
}
return try object.merge(original)
return try object.merge(with: original)
}
return API.Command<T, T>(method: .PUT,
path: object.endpoint,
Expand All @@ -457,7 +457,7 @@ internal extension API.Command {
original.hasSameObjectId(as: object) else {
return object
}
return try object.merge(original)
return try object.merge(with: original)
}
return API.Command<T, T>(method: .PATCH,
path: object.endpoint,
Expand Down
10 changes: 5 additions & 5 deletions Sources/ParseSwift/Objects/ParseInstallation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public extension ParseInstallation {
"_Installation"
}

func mergeParse(_ object: Self) throws -> Self {
func mergeParse(with object: Self) throws -> Self {
guard hasSameObjectId(as: object) == true else {
throw ParseError(code: .unknownError,
message: "objectId's of objects don't match")
Expand Down Expand Up @@ -153,8 +153,8 @@ public extension ParseInstallation {
return updatedInstallation
}

func merge(_ object: Self) throws -> Self {
try mergeParse(object)
func merge(with object: Self) throws -> Self {
try mergeParse(with: object)
}
}

Expand Down Expand Up @@ -778,7 +778,7 @@ extension ParseInstallation {
original.hasSameObjectId(as: object) else {
return object
}
return try object.merge(original)
return try object.merge(with: original)
}
return API.Command<Self, Self>(method: .PUT,
path: endpoint,
Expand All @@ -801,7 +801,7 @@ extension ParseInstallation {
original.hasSameObjectId(as: object) else {
return object
}
return try object.merge(original)
return try object.merge(with: original)
}
return API.Command<Self, Self>(method: .PATCH,
path: endpoint,
Expand Down
18 changes: 9 additions & 9 deletions Sources/ParseSwift/Objects/ParseObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public protocol ParseObject: Objectable,
/**
Merges two `ParseObject`'s with the resulting object consisting of all modified
and unchanged Parse properties.
- parameter object: The original installation.
- parameter with: The original object.
- returns: The updated installation.
- throws: An error of type `ParseError`.
- note: This is used in combination with `merge` to only send updated
properties to the server and then merge those changes with the original object.
- warning: You should only call this method and shouldn't implement it directly
as it's already implemented for developers to use.
*/
func mergeParse(_ object: Self) throws -> Self
func mergeParse(with object: Self) throws -> Self

/**
Merges two `ParseObject`'s with the resulting object consisting of all modified
Expand All @@ -103,8 +103,8 @@ public protocol ParseObject: Objectable,
var points: Int?

//: Implement your own version of merge
func merge(_ object: Self) throws -> Self {
var updated = try mergeParse(object)
func merge(with object: Self) throws -> Self {
var updated = try mergeParse(with: object)
if updated.shouldRestoreKey(\.points,
original: object) {
updated.points = object.points
Expand All @@ -113,7 +113,7 @@ public protocol ParseObject: Objectable,
}
}

- parameter object: The original object.
- parameter with: The original object.
- returns: The merged object.
- throws: An error of type `ParseError`.
- note: Use this in combination with `ParseMutable` to only send updated
Expand All @@ -124,7 +124,7 @@ public protocol ParseObject: Objectable,
in the beginning of your implementation to handle all default Parse properties. In addition,
use `shouldRestoreKey` to compare key modifications between objects.
*/
func merge(_ object: Self) throws -> Self
func merge(with object: Self) throws -> Self

init()
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public extension ParseObject {
self[keyPath: key] == nil && original[keyPath: key] != self[keyPath: key]
}

func mergeParse(_ object: Self) throws -> Self {
func mergeParse(with object: Self) throws -> Self {
guard hasSameObjectId(as: object) == true else {
throw ParseError(code: .unknownError,
message: "objectId's of objects don't match")
Expand All @@ -187,8 +187,8 @@ public extension ParseObject {
return updated
}

func merge(_ object: Self) throws -> Self {
return try mergeParse(object)
func merge(with object: Self) throws -> Self {
return try mergeParse(with: object)
}
}

Expand Down
Loading