From: The Higgs bozo on 12 Feb 2010 18:35 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 http://www.ruby-forum.com/.
First
|
Prev
|
Pages: 1 2 Prev: can you help me about this deal? Next: What is the best exception to use for bad Data State? |