Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Aug 19, 2018
1 parent 97d77e8 commit 1e25deb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
14 changes: 0 additions & 14 deletions GRDB/Record/FetchableRecord+Decodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ private struct RowDecoder<Record: FetchableRecord>: Decoder {
return nil
}

/// Decodes a value of the given type for the given key.
///
/// - parameter type: The type of value to decode.
/// - parameter key: The key that the decoded value is associated with.
/// - returns: A value of the requested type, if present for the given key and convertible to the requested type.
/// - throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
/// - throws: `DecodingError.keyNotFound` if `self` does not have an entry for the given key.
/// - throws: `DecodingError.valueNotFound` if `self` has a null entry for the given key.
func decode<T>(_ type: T.Type, forKey key: Key) throws -> T where T : Decodable {
let row = decoder.row
let keyName = key.stringValue
Expand Down Expand Up @@ -151,12 +143,6 @@ private struct RowDecoder<Record: FetchableRecord>: Decoder {
return try decode(type, fromRow: row, codingPath: codingPath + [key])
}

/// Returns the data stored for the given key as represented in a container keyed by the given key type.
///
/// - parameter type: The key type to use for the container.
/// - parameter key: The key that the nested container is associated with.
/// - returns: A keyed decoding container view into `self`.
/// - throws: `DecodingError.typeMismatch` if the encountered stored value is not a keyed container.
func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey> where NestedKey : CodingKey {
fatalError("not implemented")
}
Expand Down
12 changes: 6 additions & 6 deletions GRDB/Record/PersistableRecord+Encodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ private class RecordEncoder<Record: MutablePersistableRecord>: Encoder {
_persistenceContainer = PersistenceContainer()
}

/// Helper method
@inline(__always)
fileprivate func encode(_ value: DatabaseValueConvertible?, forKey key: CodingKey) {
_persistenceContainer[key.stringValue] = value
}

func container<Key>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> {
let container = KeyedContainer<Key>(recordEncoder: self)
return KeyedEncodingContainer(container)
Expand All @@ -37,12 +43,6 @@ private class RecordEncoder<Record: MutablePersistableRecord>: Encoder {
fatalError("single value encoding is not supported")
}

/// Helper method
@inline(__always)
fileprivate func encode(_ value: DatabaseValueConvertible?, forKey key: CodingKey) {
_persistenceContainer[key.stringValue] = value
}

private struct KeyedContainer<Key: CodingKey> : KeyedEncodingContainerProtocol {
var recordEncoder: RecordEncoder
var userInfo: [CodingUserInfoKey: Any] { return Record.databaseEncodingUserInfo }
Expand Down

0 comments on commit 1e25deb

Please sign in to comment.