Modernize actions
This commit is contained in:
parent
6ac8fb9f1d
commit
320cd15392
@ -9,16 +9,7 @@
|
|||||||
public extension Dictionary {
|
public extension Dictionary {
|
||||||
|
|
||||||
func asActionModel() throws -> ActionModelProtocol {
|
func asActionModel() throws -> ActionModelProtocol {
|
||||||
guard let castedSelf = self as? [String: Any] else {
|
return try MVMCoreActionHandler.createModel(with: self)
|
||||||
throw ModelRegistry.Error.decoderOther(message: "Dictionary is not of type [String: Any]")
|
|
||||||
}
|
|
||||||
guard let actionType = ModelRegistry.getType(for: castedSelf.stringForkey(KeyActionType), with: ActionModelProtocol.self) else {
|
|
||||||
throw ModelRegistry.Error.decoderErrorModelNotMapped()
|
|
||||||
}
|
|
||||||
guard let actionModel = try actionType.decode(jsonDict: castedSelf) as? ActionModelProtocol else {
|
|
||||||
throw ModelRegistry.Error.decoderOther(message: "Could not decode to ActionModelProtocol")
|
|
||||||
}
|
|
||||||
return actionModel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user