I have a Model, which has method_1 to method_10. I also have ModelObserver.
I would like to notifiy ModelObserver before invoking method1 to method_9, but not method_10.
Is there a DRY way to write this, instead of repeating notify_observers(:after_something) in all 9 methods?
Add a file called
monkey_patches.rbinconfig/initializersdirctory.The patch enables you to add
beforeandaftercallbacks on an instance method of a class. A hook can be:Multiple hooks can be registered on a same method. The method being hooked should come before the hook.
E.g: