What would be the equivalent of RoR observer hooks?

Hi! I am trying to build an app that has a few models that, once created, should trigger the creation of another object (specifically, a notification related to the new object). I’d want that to be handled close to the Entity/Repository so that the behavior is consistent across the app.

Callback support in the Repository seems like one way to handle it, but since those methods are include’d into my class, would I have to do the rename & new method shim to tackle it? Or is there a better practice for that in the Lotus world, something akin to the RoR observers that I’m missing?


No sure about your specific requirements but you could try Wisper gem. It allows you to set up something similar to ActiveRecord::Observer, only better because there is less coupling. Of course, I’m biased :slightly_smiling:

By the way I cannot post a link to the gem because Discourse gives me an error, “cannot post link to that host”.