refactor: rename apply_event to apply

This commit is contained in:
2026-07-29 10:44:12 -04:00
parent 511a66ab66
commit fa65782059
5 changed files with 26 additions and 17 deletions

View File

@@ -8,8 +8,10 @@ from domain.marketplace.domain_event import DomainEvent
class Entity(ABC):
_changes: tuple[DomainEvent, ...] = ()
def apply_event(self, event: DomainEvent) -> Self:
return replace(self, _changes=(*self._changes, event))
def apply(self, event: DomainEvent) -> Self:
result = self.when(event)
result._ensure_valid_state()
return replace(result, _changes=(*result._changes, event))
def get_changes(self) -> tuple[DomainEvent, ...]:
return self._changes