commit
b2ad6e88ea
|
@ -230,3 +230,40 @@ private extension Object {
|
|||
return unwrappedValue
|
||||
}
|
||||
}
|
||||
|
||||
extension Object: CustomStringConvertible {
|
||||
public var description: String {
|
||||
"""
|
||||
Object {
|
||||
\(
|
||||
variables
|
||||
.map { (key, value) in
|
||||
guard let object = value as? Object else {
|
||||
return "|\t* \(key): \(value) (\(type(of: value)))"
|
||||
}
|
||||
|
||||
let values = object.description.split(separator: "\n")
|
||||
.dropFirst()
|
||||
|
||||
if values.dropLast().isEmpty {
|
||||
return "|\t* \(key): Object { }"
|
||||
}
|
||||
|
||||
return "|\t* \(key): Object {\n\(values.map { "|\t \($0)" }.joined(separator: "\n"))"
|
||||
}
|
||||
.joined(separator: "\n")
|
||||
)
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
extension Object: Hashable {
|
||||
public static func == (lhs: Object, rhs: Object) -> Bool {
|
||||
lhs.description == rhs.description
|
||||
}
|
||||
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(description)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue