Added callback support

This commit is contained in:
2025-08-29 19:17:24 +02:00
parent 292a477298
commit 3bd503d4d2
4 changed files with 78 additions and 5 deletions

View File

@@ -224,7 +224,13 @@ editable_hook = (HookBuilder()
```
### `when_custom(condition)`
Use custom condition objects for complex logic.
Use custom condition objects or callable predicates for complex logic.
The `when_custom()` method accepts either:
- **Condition instances**: Objects that inherit from the `Condition` base class
- **Callable predicates**: Functions that take a `HookContext` parameter and return a boolean
When a callable is provided, it's automatically wrapped in a `PredicateCondition` class internally.
```python
class BusinessLogicCondition(Condition):