Skip to content

Commit faa869c

Browse files
authored
Merge pull request #38 from SportlabsTechnology/master
Fix MapInitializable initialiser
2 parents 56b4da1 + 8642de1 commit faa869c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ script:
1616
- swift build -c release
1717
- swift build
1818
- swift test
19-
- eval "$(curl -sL https://raw.githubusercontent.com/lgaches/swifttravisci/master/codecov)"
19+
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
20+
eval "$(curl -sL https://raw.githubusercontent.com/lgaches/swifttravisci/master/codecov)";
21+
fi'
2022

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let package = Package(
99
],
1010

1111
dependencies: [
12-
.package(url: "https://github.com/wickwirew/Runtime.git", from: "0.4.0"),
12+
.package(url: "https://github.com/wickwirew/Runtime.git", from: "0.6.0"),
1313
],
1414

1515
targets: [

Sources/GraphQL/Map/MapInitializable.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,19 @@ extension MapInitializable {
1010
throw MapError.cannotInitialize(type: Self.self, from: try type(of: map.get()))
1111
}
1212

13-
self = try createInstance()
14-
let info = try typeInfo(of: Self.self)
15-
16-
for property in info.properties {
13+
self = try createInstance() { property in
1714
guard let initializable = property.type as? MapInitializable.Type else {
1815
throw MapError.notMapInitializable(property.type)
1916
}
17+
2018
switch dictionary[property.name] ?? .null {
2119
case .null:
2220
guard let expressibleByNilLiteral = property.type as? ExpressibleByNilLiteral.Type else {
2321
throw RuntimeReflectionError.requiredValueMissing(key: property.name)
2422
}
25-
try property.set(value: expressibleByNilLiteral.init(nilLiteral: ()), on: &self)
23+
return expressibleByNilLiteral.init(nilLiteral: ())
2624
case let x:
27-
try property.set(value: initializable.init(map: x), on: &self)
25+
return try initializable.init(map: x)
2826
}
2927
}
3028
}

0 commit comments

Comments
 (0)