Allows replace

This commit is contained in:
Scott Pfeil 2022-01-10 11:36:54 -05:00
parent 6fe6d6ea8b
commit a2d9196bca

View File

@ -40,9 +40,9 @@ public struct ModelRegistry {
/// - Parameters:
/// - handler: The handling class taking an object of ModelHandlerProtocol.self which is used to register
/// - model: The data object of ModelProtocol.self which is used to register
public static func register<H: ModelHandlerProtocol, M: ModelProtocol>(handler: H.Type, for model: M.Type) {
public static func register<H: ModelHandlerProtocol, M: ModelProtocol>(handler: H.Type, for model: M.Type, allowsReplace: Bool = false) {
do {
try throwable_register(handler: handler, model: model)
try throwable_register(handler: handler, model: model, allowsReplace: allowsReplace)
} catch {
handleError(error)
}
@ -126,7 +126,7 @@ public struct ModelRegistry {
/// - Throws: An Error object of `ModelRegistry.Error`
public static func throwable_register<H: ModelHandlerProtocol, M: ModelProtocol>(handler: H.Type, model: M.Type, allowsReplace: Bool = false) throws {
// Register the type
try self.throwable_register(type: model)
try self.throwable_register(type: model, allowsReplace: allowsReplace)
// Get the key for the handler
let key = model.identifier