File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,17 +118,6 @@ public final class Hook {
118118 }
119119 }
120120
121- /// Validate that the selector exists on the active class.
122- @discardableResult func validate( expectedState: HookState = . pending) throws -> Method {
123- guard let method = class_getInstanceMethod ( `class`, selector) else {
124- throw InterposeError . methodNotFound ( `class`, selector)
125- }
126- guard state == expectedState else {
127- throw InterposeError . invalidState ( expectedState: expectedState)
128- }
129- return method
130- }
131-
132121 private func execute( newState: HookState , task: ( ) throws -> Void ) throws {
133122 do {
134123 try task ( )
Original file line number Diff line number Diff line change @@ -113,12 +113,14 @@ final public class Interpose {
113113 if let task = task {
114114 try task ( self )
115115 }
116+
116117 // Validate all tasks, stop if anything is not valid
117- guard hooks . allSatisfy ( {
118- ( try ? $0 . validate ( expectedState : expectedState ) ) != nil
119- } ) else {
120- throw InterposeError . invalidState ( expectedState : expectedState )
118+ for hook in self . hooks {
119+ if hook . state != expectedState {
120+ throw InterposeError . invalidState ( expectedState : expectedState )
121+ }
121122 }
123+
122124 // Execute all tasks
123125 try hooks. forEach ( executor)
124126 return self
You can’t perform that action at this time.
0 commit comments