module
Lustra::Model::HasHooks::ClassMethods
Defined in:
lustra/model/modules/has_hooks.crInstance Method Summary
-
#after(event_name : Symbol, &block : Lustra::Model -> Nil)
Register a callback to be executed AFTER the specified lifecycle event
-
#before(event_name : Symbol, &block : Lustra::Model -> Nil)
Register a callback to be executed BEFORE the specified lifecycle event
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 }
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 }