Hooks
ActiveRecordHooksBase
TH: I think I read somewhere that Interceptors are now the preferred approach over hooks - can someone confirm or deny via editing.
Sometimes it's necessary to interfere in the process of saving, loading or deletion. In order to do that, simply override the available hooks:
- BeforeSave(IDictionary state)
- BeforeLoad(IDictionary state)
- BeforeDelete(IDictionary state)
Suppose you want to enforce the current date/time when a post is created:
protected override bool BeforeSave(IDictionary state) { state["Created"] = DateTime.Now; return true; }
