diff --git a/Sources/Extractor.swift b/Sources/Extractor.swift index 45f0005..ea92ed8 100644 --- a/Sources/Extractor.swift +++ b/Sources/Extractor.swift @@ -72,17 +72,15 @@ public struct Extractor { } /// - Throws: DecodeError or an arbitrary ErrorType + @available(*, unavailable, renamed: "value(_:)") public func array(_ keyPath: KeyPath) throws -> [T] { - guard let array: [T] = try arrayOptional(keyPath) else { - throw DecodeError.missingKeyPath(keyPath) - } - - return array + fatalError() } /// - Throws: DecodeError or an arbitrary ErrorType + @available(*, unavailable, renamed: "valueOptional(_:)") public func arrayOptional(_ keyPath: KeyPath) throws -> [T]? { - return try _rawValue(keyPath).map([T].decode) + fatalError() } /// - Throws: DecodeError or an arbitrary ErrorType diff --git a/Sources/Operators.swift b/Sources/Operators.swift index 0e31f47..52292d1 100644 --- a/Sources/Operators.swift +++ b/Sources/Operators.swift @@ -26,13 +26,13 @@ public func <|? (e: Extractor, keyPath: KeyPath) throws -> T? { /// - Throws: DecodeError or an arbitrary ErrorType @available(*, unavailable, renamed: "<|") public func <|| (e: Extractor, keyPath: KeyPath) throws -> [T] { - return try e.array(keyPath) + fatalError() } /// - Throws: DecodeError or an arbitrary ErrorType @available(*, unavailable, renamed: "<|?") public func <||? (e: Extractor, keyPath: KeyPath) throws -> [T]? { - return try e.arrayOptional(keyPath) + fatalError() } /// - Throws: DecodeError or an arbitrary ErrorType diff --git a/Sources/StandardLib.swift b/Sources/StandardLib.swift index dd33a0c..f6aee04 100644 --- a/Sources/StandardLib.swift +++ b/Sources/StandardLib.swift @@ -74,12 +74,12 @@ extension Array: Decodable where Element: Decodable { /// - Throws: DecodeError or an arbitrary ErrorType public static func decode(from data: Data, rootKeyPath: KeyPath) throws -> [Element] { - return try Extractor(from: data).array(rootKeyPath) + return try Extractor(from: data).value(rootKeyPath) } /// - Throws: DecodeError or an arbitrary ErrorType public static func decode(_ JSON: Any, rootKeyPath: KeyPath) throws -> [Element] { - return try Extractor(JSON).array(rootKeyPath) + return try Extractor(JSON).value(rootKeyPath) } } diff --git a/Tests/HimotokiTests/TransformerTest.swift b/Tests/HimotokiTests/TransformerTest.swift index 4a3b30a..a2b3347 100644 --- a/Tests/HimotokiTests/TransformerTest.swift +++ b/Tests/HimotokiTests/TransformerTest.swift @@ -32,7 +32,7 @@ private struct URLsByTransformer: Himotoki.Decodable { return self.init( value: try Transformer { try toURL($0) }.apply(e <| "value"), valueOptional: try URLTransformer.apply(e.valueOptional("valueOptional")), - array: try URLTransformer.apply(e.array("array")), + array: try URLTransformer.apply(e.value("array")), arrayOptional: try URLTransformer.apply(e <|? "arrayOptional"), dictionary: try URLTransformer.apply(e <| "dictionary"), dictionaryOptional: try URLTransformer.apply(e.dictionaryOptional("dictionaryOptional"))