-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adopt Mapper for Map * Fixed inner dependencies
- Loading branch information
1 parent
85166f8
commit 534a6e1
Showing
5 changed files
with
79 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@_exported import Reflection | ||
@_exported import POSIX | ||
@_exported import Mapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
extension Map : InMap { | ||
|
||
public func get(at indexPath: IndexPathValue) -> Map? { | ||
return try? self.get([indexPath]) | ||
} | ||
|
||
public func asArray() -> [Map]? { | ||
if case .array(let array) = self { | ||
return array | ||
} | ||
return nil | ||
} | ||
|
||
public func get<T>() -> T? { | ||
return self.get() | ||
} | ||
|
||
} | ||
|
||
extension Map : OutMap { | ||
|
||
public static var blank: Map { | ||
return .dictionary([:]) | ||
} | ||
|
||
public mutating func set(_ map: Map, at indexPath: IndexPathValue) throws { | ||
try self.set(map, for: indexPath) | ||
} | ||
|
||
public static func fromArray(_ array: [Map]) -> Map? { | ||
return .array(array) | ||
} | ||
|
||
public static func from<T>(_ value: T) -> Map? { | ||
if let representable = value as? MapRepresentable { | ||
return representable.map | ||
} | ||
return nil | ||
} | ||
|
||
public static func from(_ int: Int) -> Map? { | ||
return .int(int) | ||
} | ||
|
||
public static func from(_ double: Double) -> Map? { | ||
return .double(double) | ||
} | ||
|
||
public static func from(_ string: String) -> Map? { | ||
return .string(string) | ||
} | ||
|
||
public static func from(_ bool: Bool) -> Map? { | ||
return .bool(bool) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters