module Lustra::Model::HasHooks::ClassMethods

Defined in:

lustra/model/modules/has_hooks.cr

Instance Method Summary

Instance Method Detail

def after(event_name : Symbol, &block : Lustra::Model -> Nil) #

Register a callback to be executed AFTER the specified lifecycle event

event_name - the lifecycle event (:create, :update, :validate, etc.) block - the callback block to execute

Example: after(:create) { |model| model.send_welcome_email }


[View source]
def before(event_name : Symbol, &block : Lustra::Model -> Nil) #

Register a callback to be executed BEFORE the specified lifecycle event

event_name - the lifecycle event (:create, :update, :validate, etc.) block - the callback block to execute

Example: before(:validate) { |model| model.sanitize_data }


[View source]