Delete unused code in Author.

This commit is contained in:
Brent Simmons 2019-03-12 21:52:21 -07:00
parent 64256eb4e6
commit dd39e3a0fe
1 changed files with 0 additions and 50 deletions

View File

@ -17,7 +17,6 @@ public struct Author: Codable, Hashable {
public let emailAddress: String?
public init?(authorID: String?, name: String?, url: String?, avatarURL: String?, emailAddress: String?) {
if name == nil && url == nil && emailAddress == nil {
return nil
}
@ -38,41 +37,6 @@ public struct Author: Codable, Hashable {
}
}
public struct Key {
static let authorID = "authorID"
static let name = "name"
static let url = "url"
static let avatarURL = "avatarURL"
static let emailAddress = "emailAddress"
}
public init?(dictionary: [String: Any]) {
self.init(authorID: dictionary[Key.authorID] as? String, name: dictionary[Key.name] as? String, url: dictionary[Key.url] as? String, avatarURL: dictionary[Key.avatarURL] as? String, emailAddress: dictionary[Key.emailAddress] as? String)
}
public var dictionary: [String: Any] {
var d = [String: Any]()
d[Key.authorID] = authorID
if let name = name {
d[Key.name] = name
}
if let url = url {
d[Key.url] = url
}
if let avatarURL = avatarURL {
d[Key.avatarURL] = avatarURL
}
if let emailAddress = emailAddress {
d[Key.emailAddress] = emailAddress
}
return d
}
public static func authorsWithJSON(_ jsonString: String) -> Set<Author>? {
// This is JSON stored in the database, not the JSON Feed version of an author.
guard let data = jsonString.data(using: .utf8) else {
@ -89,24 +53,10 @@ public struct Author: Codable, Hashable {
}
return nil
}
public static func authorsWithDiskArray(_ diskArray: [[String: Any]]) -> Set<Author>? {
let authors = diskArray.compactMap { Author(dictionary: $0) }
return authors.isEmpty ? nil : Set(authors)
}
}
extension Set where Element == Author {
public func diskArray() -> [[String: Any]]? {
if self.isEmpty {
return nil
}
return self.map{ $0.dictionary }
}
public func json() -> String? {
let encoder = JSONEncoder()
do {