Updating last thing for setting up tables to Postgres-StORM
This commit is contained in:
parent
6b468a6f22
commit
11d32ea7b6
|
@ -82,13 +82,15 @@ extension Bool {
|
||||||
}
|
}
|
||||||
//MARK: - Mirror Array:
|
//MARK: - Mirror Array:
|
||||||
extension Array where Iterator.Element == Mirror {
|
extension Array where Iterator.Element == Mirror {
|
||||||
var allChildren : [String:Any] {
|
func allChildren(includingNilValues: Bool=false) -> [String:Any] {
|
||||||
var allChild : [String:Any] = [:]
|
var allChild : [String:Any] = [:]
|
||||||
for mirror in self {
|
for mirror in self {
|
||||||
mirror.children.forEach({ (child) in
|
mirror.children.forEach({ (child) in
|
||||||
// Make sure our child has a label & the string describing the value is not nil. (Making optionals supported)
|
// Make sure our child has a label & the string describing the value is not nil. (Making optionals supported)
|
||||||
if let label = child.label, String(describing: child.value) != "nil" {
|
if !includingNilValues {
|
||||||
allChild[label] = child.value
|
if let label = child.label, String(describing: child.value) != "nil" {
|
||||||
|
allChild[label] = child.value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
public protocol CCXMirroring {
|
public protocol CCXMirroring {
|
||||||
func didInitializeSuperclass()
|
func didInitializeSuperclass()
|
||||||
func allChildren() -> [String:Any]
|
func allChildren(includingNilValues : Bool) -> [String:Any]
|
||||||
}
|
}
|
||||||
|
|
||||||
open class CCXMirror: CCXMirroring {
|
open class CCXMirror: CCXMirroring {
|
||||||
|
@ -55,9 +55,9 @@ open class CCXMirror: CCXMirroring {
|
||||||
return mirrors
|
return mirrors
|
||||||
}
|
}
|
||||||
/// This returns all the children, even all the superclass mirrored children. Use allChildren().asData() to return an array of key/values.
|
/// This returns all the children, even all the superclass mirrored children. Use allChildren().asData() to return an array of key/values.
|
||||||
public func allChildren() -> [String:Any] {
|
public func allChildren(includingNilValues : Bool = false) -> [String:Any] {
|
||||||
// Remove out the superclass count which is private:
|
// Remove out the superclass count which is private:
|
||||||
var children = self.superclassMirrors().allChildren
|
var children = self.superclassMirrors().allChildren(includingNilValues: includingNilValues)
|
||||||
children.removeValue(forKey: "superclassCount")
|
children.removeValue(forKey: "superclassCount")
|
||||||
return children
|
return children
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue