For this purpose, Aspect Oriented Programming (wikipedia) seems to be a more organized solution than comefrom . See Bottom of Motivation and Basic Concepts (ibid) for an example of how registration can be added to a method in a separate text unit.
In a fairly dynamic language, you can handle these things with the help of βwrapβ modifiers prior to the method:
def do_something ... end log :do_something, "Something got done"
In this far-fetched example, the log macro causes the do_something method to be replaced with a new method, which first calls the original do_something method and then writes something to the log.
Wayne conrad
source share