The run_callbacks_for_* method calls a given block with invoking callbacks in the following phase order:
class Record Callback.enable define_callback_group :save before_save do puts "before" end around_save do puts "around" end after_save do puts "after" end on_save do puts "on" end def save run_callbacks_for_save do puts "yield" end end end rec = Record.new rec.save
This prints:
before around on yield around after
You can access a T instance by the first argument in callbacks.
class Record Callback.enable define_callback_group :save before_save do |o| o.validate end def validate puts "validate" end def save run_callbacks_for_save do puts "save" end end end rec = Record.new rec.save
validate save
There was an error while loading. Please reload this page.