Modernize actions

This commit is contained in:
Scott Pfeil 2022-07-01 15:26:09 -04:00
parent 6ac8fb9f1d
commit 320cd15392

View File

@ -9,16 +9,7 @@
public extension Dictionary {
func asActionModel() throws -> ActionModelProtocol {
guard let castedSelf = self as? [String: Any] else {
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
return try MVMCoreActionHandler.createModel(with: self)
}
}