Slather logo

Coverage for "BaseEntitiesCollector.swift" : 100.00%

(11 of 11 relevant lines covered)

RouteComposer/Classes/Assemblies/Helpers/BaseEntitiesCollector.swift

1
//
2
// RouteComposer
3
// BaseEntitiesCollector.swift
4
// https://github.com/ekazaev/route-composer
5
//
6
// Created by Eugene Kazaev in 2018-2022.
7
// Distributed under the MIT license.
8
//
9
// Become a sponsor:
10
// https://github.com/sponsors/ekazaev
11
//
12
13
import Foundation
14
import UIKit
15
16
struct BaseEntitiesCollector<FactoryBoxer: AnyFactoryBox, ActionBoxer: AnyActionBox>: EntitiesProvider {
17
18
    let factory: AnyFactory?
19
20
    let finder: AnyFinder?
21
22
    init<F: Finder>(finder: F, factory: FactoryBoxer.FactoryType, action: ActionBoxer.ActionType)
23
        where
24
        F.ViewController == FactoryBoxer.FactoryType.ViewController, F.Context == FactoryBoxer.FactoryType.Context {
277x
25
        self.finder = FinderBox(finder)
277x
26
277x
27
        if let factoryBox = FactoryBoxer(factory, action: ActionBoxer(action)) {
277x
28
            self.factory = factoryBox
179x
29
        } else if let finderFactory = FinderFactory(finder: finder) {
277x
30
            self.factory = FactoryBox(finderFactory, action: ActionBox(ViewControllerActions.NilAction()))
78x
31
        } else {
277x
32
            self.factory = nil
199x
33
        }
277x
34
    }
277x
35
36
}