Lustra::Model::HasHooks::ClassMethods
Instance methods
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
Note: The block parameter has type Lustra::Model. Use .as(YourModel) to access
model-specific methods and columns.
Example:
after(:create) do |model|
user = model.as(User)
user.send_welcome_email
end
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
Note: The block parameter has type Lustra::Model. Use .as(YourModel) to access
model-specific methods and columns.
Example:
before(:validate) do |model|
user = model.as(User)
user.email = user.email.downcase
end