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