module Jennifer::Model::Callback
Overview
Callbacks are hooks into the life cycle of a model object that allow you to trigger logic before or after an alteration of the object state.
class User < Jennifer::Model::Base
  # mapping()
  before_save :notify
  after_create :send_email, if: admin?
  def notify
    # ...
  end
  def admin?
    role == "admin"
  end
end
  Direct including types
Defined in:
jennifer/model/callback.crMacro Summary
- 
        after_commit(*names, on)
        
          
Defines callbacks which are called after a record has been created, updated, or destroyed.
 - 
        after_create(*names)
        
          
Defines callbacks which are called after
Base.saveon new objects that haven’t been saved yet (no record exists). - 
        after_destroy(*names)
        
          
Defines callbacks which are called after
Base.destroy. - 
        after_initialize(*names)
        
          
Defines callbacks which are called after
Base.buildcall. - 
        after_rollback(*names, on)
        
          
Defines callbacks which are called after a create, update, or destroy are rolled back.
 - 
        after_save(*names)
        
          
Defines callbacks which are called after
Base.save(regardless of whether it's acreateorupdatesave). - 
        after_update(*names)
        
          
Defines callbacks which are called after
Base.saveon existing objects that have a record. - 
        after_validation(*names)
        
          
Defines callbacks which are called after
Base.validate!(which is part of theBase.savecall). - 
        before_create(*names)
        
          
Defines callbacks which are called before
Base.saveon new objects that haven’t been saved yet (no record exists). - 
        before_destroy(*names)
        
          
Defines callbacks which are called before
Base.destroy - 
        before_save(*names)
        
          
Defines callbacks which are called before
Base.save(regardless of whether it's acreateorupdatesave). - 
        before_update(*names)
        
          
Defines callbacks which are called before
Base.saveon existing objects that have a record. - 
        before_validation(*names)
        
          
Defines callbacks which are called before
Base.validate!(which is part of theBase.savecall). 
Macro Detail
Defines callbacks which are called after a record has been created, updated, or destroyed.
You can specify that the callback should only be fired by a certain action with the :on option:
after_commit :var, on: :save
after_commit :foo, on: :create
after_commit :bar, on: :update
after_commit :baz, on: :destroy
        Defines callbacks which are called after Base.save on new objects that haven’t been saved yet
(no record exists).
Note that these callbacks is still wrapped in the transaction around save.
Defines callbacks which are called after a create, update, or destroy are rolled back.
Please check the documentation of after_commit macro for options.
Defines callbacks which are called after Base.save (regardless of whether it's a create or update save).
Note that these callbacks are still wrapped in the transaction around save.
Defines callbacks which are called after Base.save on existing objects that have a record.
Note that these callbacks are still wrapped in the transaction around save.
Defines callbacks which are called after Base.validate! (which is part of the Base.save call).
Defines callbacks which are called before Base.save on new objects that haven’t been saved yet
(no record exists).
Note that these callbacks are already wrapped in the transaction around save.
Defines callbacks which are called before Base.save (regardless of whether it's a create or update save).
Note that these callbacks are already wrapped in the transaction around save.
Defines callbacks which are called before Base.save on existing objects that have a record.
Note that these callbacks are already wrapped in the transaction around save.