Say, I have a RoR application with multiple plugins. Each of these plugins implements an after_save callback on a model. I need to create one more plugin with two more callbacks, say, start and finish. How do I ensure the following order of callback execution?
- MyPlugin.start
- OtherPlugin_1.after_save_1
- OtherPlugin_1.after_save_X
- OtherPlugin_X.after_save_1
- ...
- MyPlugin.finish
I.e. my callback should be called before any other after_save and immediately after all other after_save callbacks have finished execution.
This should be possible by using
prepend: truefor MyPlugin.start, as follows:Assuming, that no other plugin uses
:prepend.Regarding MyPlugin.finish: the only option (as far as I know) is to make sure, that the plugin is executed last (e.g., by naming it
zzz).