Updating naming conventions of the extensions/mirroring protocol

This commit is contained in:
Ryan Coyne 2017-12-01 11:38:53 -05:00
parent cb25dd757e
commit 7f42d5552f
3 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,7 @@ open class StORM : StORMMirror {
return c
}
/// This modifyValue function now supports optional variables and forces the value as the type it is, so that the String(describing) doesn't include the optional string wrapping the actual value.
open func modifyValue(_ v: Any, forKey k: String) -> Any {
guard String(describing: v) != "nil" else { return v }

View File

@ -83,6 +83,8 @@ extension Bool {
}
//MARK: - Mirror Array:
extension Array where Iterator.Element == Mirror {
/// This function will automatically return the created/modified values IF your model has a variable with that name. Created/modified are intended to be integer values of UTC time since 1970.
/// Createdby/Modifiedby fields are automatically supported at the database level in PostgresStORM.
func allChildren(includingNilValues: Bool = false, primaryKey: String? = nil) -> [Mirror.Child] {
var allChild : [Mirror.Child] = []
for mirror in self {

View File

@ -44,6 +44,7 @@ open class StORMMirror: StORMMirroring {
return mirrors
}
/// This returns all the children, even all the superclass mirrored children. Use allChildren().asData() to return an array of key/values.
/// The includingNilValues optional parameter is used to return the mirror children even if the value is nil.
public func allChildren(includingNilValues : Bool = false, primaryKey: String? = nil) -> [Mirror.Child] {
// Remove out the superclass count which is private:
let children = self.superclassMirrors().allChildren(includingNilValues: includingNilValues, primaryKey: primaryKey)