Module: ActiveMigration::Callbacks
- Defined in:
- lib/active_migration/callbacks.rb
Overview
Callbacks are hooks into the ActiveMigration migration lifecycle. This typical flow is below. Bold items are internal calls.
- before_run
- *run*
- before_migrate_record
- *migrate_record*
- after_migrate_record
- before_migrate_field
- *migrate_field*
- after_migrate_field
- before_save (before_create, before_update)
- *save*
- after_save (after_create, after_update)
- after_run
Constant Summary collapse
- CALLBACKS =
%w(before_run after_run before_migrate_record after_migrate_record before_migrate_field after_migrate_field before_save after_save before_create after_create before_update after_update)
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#after_create ⇒ Object
This is only called after update if active_record_mode is set to :create(default).
-
#after_migrate_field ⇒ Object
This is called directly after each field migration.
-
#after_migrate_record ⇒ Object
This is called after the iteration of field migrations.
-
#after_run ⇒ Object
This is called after everything else finishes.
-
#after_save ⇒ Object
This is called directly after the active record is saved.
-
#after_update ⇒ Object
This is only called after update if active_record_mode is set to :update.
-
#before_create ⇒ Object
This is only called before create if active_record_mode is set to :create(default).
-
#before_migrate_field ⇒ Object
This is called before each field migration.
-
#before_migrate_record ⇒ Object
This is called before the iteration of field migrations.
-
#before_run ⇒ Object
This is called before you anything actually starts.
-
#before_save ⇒ Object
This is called directly before the active record is saved.
-
#before_update ⇒ Object
This is only called before update if active_record_mode is set to :update.
- #create_with_callbacks ⇒ Object
-
#migrate_field_with_callbacks ⇒ Object
:nodoc:.
-
#migrate_record_with_callbacks ⇒ Object
:nodoc:.
-
#run_with_callbacks ⇒ Object
:nodoc:.
- #save_with_callbacks ⇒ Object
- #update_with_callbacks ⇒ Object
Class Method Details
.included(base) ⇒ Object
:nodoc:
26 27 28 29 30 31 32 |
# File 'lib/active_migration/callbacks.rb', line 26 def self.included(base)#:nodoc: [:run, :migrate_record, :migrate_field, :save, :update, :create].each do |method| base.send :alias_method_chain, method, :callbacks end base.send :include, ActiveSupport::Callbacks base.define_callbacks *CALLBACKS end |
Instance Method Details
#after_create ⇒ Object
This is only called after update if active_record_mode is set to :create(default).
99 |
# File 'lib/active_migration/callbacks.rb', line 99 def after_create() end |
#after_migrate_field ⇒ Object
This is called directly after each field migration.
63 |
# File 'lib/active_migration/callbacks.rb', line 63 def after_migrate_field() end |
#after_migrate_record ⇒ Object
This is called after the iteration of field migrations.
51 |
# File 'lib/active_migration/callbacks.rb', line 51 def after_migrate_record() end |
#after_run ⇒ Object
This is called after everything else finishes.
39 |
# File 'lib/active_migration/callbacks.rb', line 39 def after_run() end |
#after_save ⇒ Object
This is called directly after the active record is saved.
75 |
# File 'lib/active_migration/callbacks.rb', line 75 def after_save() end |
#after_update ⇒ Object
This is only called after update if active_record_mode is set to :update.
87 |
# File 'lib/active_migration/callbacks.rb', line 87 def after_update() end |
#before_create ⇒ Object
This is only called before create if active_record_mode is set to :create(default).
96 |
# File 'lib/active_migration/callbacks.rb', line 96 def before_create() end |
#before_migrate_field ⇒ Object
This is called before each field migration.
60 |
# File 'lib/active_migration/callbacks.rb', line 60 def before_migrate_field() end |
#before_migrate_record ⇒ Object
This is called before the iteration of field migrations.
48 |
# File 'lib/active_migration/callbacks.rb', line 48 def before_migrate_record() end |
#before_run ⇒ Object
This is called before you anything actually starts.
36 |
# File 'lib/active_migration/callbacks.rb', line 36 def before_run() end |
#before_save ⇒ Object
This is called directly before the active record is saved.
72 |
# File 'lib/active_migration/callbacks.rb', line 72 def before_save() end |
#before_update ⇒ Object
This is only called before update if active_record_mode is set to :update.
84 |
# File 'lib/active_migration/callbacks.rb', line 84 def before_update() end |
#create_with_callbacks ⇒ Object
100 101 102 103 104 |
# File 'lib/active_migration/callbacks.rb', line 100 def create_with_callbacks callback(:before_create) create_without_callbacks callback(:after_create) end |
#migrate_field_with_callbacks ⇒ Object
:nodoc:
64 65 66 67 68 |
# File 'lib/active_migration/callbacks.rb', line 64 def migrate_field_with_callbacks#:nodoc: callback(:before_migrate_field) migrate_field_without_callbacks callback(:after_migrate_field) end |
#migrate_record_with_callbacks ⇒ Object
:nodoc:
52 53 54 55 56 |
# File 'lib/active_migration/callbacks.rb', line 52 def migrate_record_with_callbacks #:nodoc: callback(:before_migrate_record) migrate_record_without_callbacks callback(:after_migrate_record) end |
#run_with_callbacks ⇒ Object
:nodoc:
40 41 42 43 44 |
# File 'lib/active_migration/callbacks.rb', line 40 def run_with_callbacks #:nodoc: callback(:before_run) run_without_callbacks callback(:after_run) end |
#save_with_callbacks ⇒ Object
76 77 78 79 80 |
# File 'lib/active_migration/callbacks.rb', line 76 def save_with_callbacks callback(:before_save) save_without_callbacks callback(:after_save) end |
#update_with_callbacks ⇒ Object
88 89 90 91 92 |
# File 'lib/active_migration/callbacks.rb', line 88 def update_with_callbacks callback(:before_update) update_without_callbacks callback(:after_update) end |