mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Extension methods use the converter and wrap the static prisms.
This commit is contained in:
parent
806ea1ea93
commit
1ec7e5b06c
@ -72,23 +72,23 @@ extension JSONConvertible {
|
||||
|
||||
extension Prism where To : JSONConvertible {
|
||||
public var number: Prism<From, Double> {
|
||||
return self >>> Prism<To, Double>(forward: { $0.JSON.number }, backward: { To(JSON: .Number($0)) })
|
||||
return self >>> To.JSONConverter >>> Doubt.JSON.number
|
||||
}
|
||||
|
||||
public var boolean: Prism<From, Bool> {
|
||||
return self >>> Prism<To, Bool>(forward: { $0.JSON.boolean }, backward: { To(JSON: .Boolean($0)) })
|
||||
return self >>> To.JSONConverter >>> Doubt.JSON.boolean
|
||||
}
|
||||
|
||||
public var string: Prism<From, Swift.String> {
|
||||
return self >>> Prism<To, Swift.String>(forward: { $0.JSON.string }, backward: { To(JSON: .String($0)) })
|
||||
return self >>> To.JSONConverter >>> Doubt.JSON.string
|
||||
}
|
||||
|
||||
public var array: Prism<From, [Doubt.JSON]> {
|
||||
return self >>> Prism<To, [Doubt.JSON]>(forward: { $0.JSON.array }, backward: { To(JSON: .Array($0)) })
|
||||
return self >>> To.JSONConverter >>> Doubt.JSON.array
|
||||
}
|
||||
|
||||
public var dictionary: Prism<From, [String:Doubt.JSON]> {
|
||||
return self >>> Prism<To, [String:Doubt.JSON]>(forward: { $0.JSON.dictionary }, backward: { To(JSON: .Dictionary($0)) })
|
||||
return self >>> To.JSONConverter >>> Doubt.JSON.dictionary
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user