-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed tests Co-authored-by: AG <[email protected]>
- Loading branch information
Showing
16 changed files
with
238 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Gr4vyConnectionOptionsValue.swift | ||
// gr4vy-ios | ||
// | ||
// | ||
|
||
import Foundation | ||
|
||
public enum Gr4vyConnectionOptionsValue: Codable { | ||
case string(String) | ||
case int(Int) | ||
case bool(Bool) | ||
case double(Double) | ||
|
||
private enum CodingError: Error { | ||
case unknownValue | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
if let boolValue = try? container.decode(Bool.self) { | ||
self = .bool(boolValue) | ||
} else if let intValue = try? container.decode(Int.self) { | ||
self = .int(intValue) | ||
} else if let doubleValue = try? container.decode(Double.self) { | ||
self = .double(doubleValue) | ||
} else if let stringValue = try? container.decode(String.self) { | ||
self = .string(stringValue) | ||
} else { | ||
throw CodingError.unknownValue | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
switch self { | ||
case .string(let value): | ||
try container.encode(value) | ||
case .int(let value): | ||
try container.encode(value) | ||
case .bool(let value): | ||
try container.encode(value) | ||
case .double(let value): | ||
try container.encode(value) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.