From: The Higgs bozo on
Xeno Campanoli wrote:
> I have an initialize method I want to run at the end of any daughter or
> granddaughter 'initialize' to make sure the state has been created
> properly, and
> I would rather specify the execution from the base class itself than
> count on
> those descendents to do it.

This is a designed-in feature of Common Lisp, where you can define
:after methods which do what you describe (there's also :before and
:around methods too).

I thought I saw Ruby 2.0 prototype code for something similar (:pre and
:post methods?), but I can't seem find the reference now.

A possible long-term solution (which begins as an experiment) is to go
the whole nine yards: design the spec for :pre and :post methods (maybe
:around too), implement it, and publish the gem. Refine until it starts
to crystallize. Then use the gem.

(It's not overly clever if there's a clean API together with a boatload
of tests, in my opinion.)
Posted via