Module: ActiveRecordCompose::Callbacks

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Validations::Callbacks
Included in:
Persistence
Defined in:
lib/active_record_compose/callbacks.rb

Overview

Provides hooks into the life cycle of an ActiveRecordCompose model, allowing you to insert custom logic before or after changes to the object's state.

The callback flow generally follows the same structure as Active Record:

  • before_validation
  • after_validation
  • before_save
  • before_create (or before_update for update operations)
  • after_create (or after_update for update operations)
  • after_save
  • after_commit (or after_rollback when the transaction is rolled back)

Class Method Summary collapse

Class Method Details

.after_create(*args, &block) ⇒ void

Registers a callback to be called after a model is created.



42
# File 'lib/active_record_compose/callbacks.rb', line 42

define_model_callbacks :create

.after_save(*args, &block) ⇒ void

Registers a callback to be called after a model is saved.



31
# File 'lib/active_record_compose/callbacks.rb', line 31

define_model_callbacks :save

.after_update(*args, &block) ⇒ void

Registers a callback to be called after a update is updated.



52
# File 'lib/active_record_compose/callbacks.rb', line 52

define_model_callbacks :update

.around_create(*args, &block) ⇒ void

Registers a callback to be called around the creation of a model.



# File 'lib/active_record_compose/callbacks.rb', line 36

.around_save(*args, &block) ⇒ void

Registers a callback to be called around the save of a model.



# File 'lib/active_record_compose/callbacks.rb', line 25

.around_update(*args, &block) ⇒ void

Registers a callback to be called around the update of a model.



# File 'lib/active_record_compose/callbacks.rb', line 47

.before_create(*args, &block) ⇒ void

Registers a callback to be called before a model is created.



# File 'lib/active_record_compose/callbacks.rb', line 33

.before_save(*args, &block) ⇒ void

Registers a callback to be called before a model is saved.



# File 'lib/active_record_compose/callbacks.rb', line 22

.before_update(*args, &block) ⇒ void

Registers a callback to be called before a model is updated.



# File 'lib/active_record_compose/callbacks.rb', line 44