Skip to content

Commit e2b1422

Browse files
committed
Eliminated obsolete Hook.validate(…) method
1 parent 7b3272a commit e2b1422

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

Sources/InterposeKit/Hooks/Hook.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff 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()

Sources/InterposeKit/Interpose.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)