Move function for scoping purposes
This commit is contained in:
parent
d1239eda74
commit
48388343ef
@ -23,3 +23,19 @@ public extension PageBehaviorHandlerModelProtocol {
|
|||||||
self.behaviors = newBehaviors
|
self.behaviors = newBehaviors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension PageBehaviorHandlerModelProtocol where Self: MoleculeTreeTraversalProtocol {
|
||||||
|
|
||||||
|
/// Traverses all models and adds any required behavior models.
|
||||||
|
mutating func traverseAndAddRequiredBehaviors() {
|
||||||
|
let behaviorModels: [PageBehaviorModelProtocol] = reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, molecule, depth) in
|
||||||
|
if let behaviorRequirer = molecule as? PageBehaviorProtocolRequirer {
|
||||||
|
return accumulator + behaviorRequirer.getRequiredBehaviors()
|
||||||
|
}
|
||||||
|
return accumulator
|
||||||
|
}
|
||||||
|
for behavior in behaviorModels {
|
||||||
|
add(behavior: behavior)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user