From: Austin Ziegler Date: 2004-08-06T02:50:41+09:00 Subject: Re: Macros in Ruby On Fri, 6 Aug 2004 01:31:28 +0900, Ara.T.Howard wrote: > i actually use them quite a bit and would appreciate a shortcut. i sometimes > prefer to have modifiable Proc attributes of object to parameterize their > behaviour rather than messing with inheritence or dynamic redefinition. i > also end up writing methods which take options callbacks for > debugging/logging, eg: I'd do this as: def long_db_update(arg, callback = nil) sql = gen_sql(arg) callback.pre(sql) if callback.respond_to?(:pre) res = if callback.respond_to?(:pan) t = Thread.new(Thread.current) do |c| begin execute(sql) rescue => e c.raise (e) end end loop do break unless t.status callback.pan(get_state) sleep 0.42 end t.join t.value else execute(sql) end callback.post(res) if callback.respond_to?(:post) res end Then I can create my callback object. With this, I could easily plug in a debug object (predefined), a GUI object, or anything else, and my callback becomes part of my defined API. (I would actually even go as far as modifying callback.post so that its return may optionally modify res.) -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca