annotation Athena::ORM::Annotations::PreUpdate
#
Marks a method to be called right before a changed entity is updated, during AORM::EntityManager#flush.
It doesn't run for entities without changes.
@[AORMA::Entity]
class Post < AORM::Entity
# ...
@[AORMA::Column]
property! updated_at : Time
@[AORMA::PreUpdate]
def set_updated_at : Nil
@updated_at = Time.utc
end
end
Changes made by the callback to the entity's columns are written by the same UPDATE.
Changes to its collections are not.
See AORMA::PrePersist for the rules every lifecycle callback follows.