ha! that's funny, that's exactly what i was working towards! thanks for
the help in that direction. actually though, i gave the example just to
show you how much i was passing self. but i didn't give an explination
--the reason i have to pass self is that the subrecords have actions
too, as you can see in the action method. when one of those those
actions is "hit upon" they SOMETIMES need to call customers display
routine to finish up. i suppose i could pass a request back up to
customer to take care of this. but that raises an interesting point and
question: is it good coding not to pass self? and instead pass messages
to trigger various realted objects to do certain things? or doses it
amount to the same thing?

~transami


On Sat, 2002-07-06 at 08:34, Dave Thomas wrote:
> Tom Sawyer <transami / transami.net> writes:
> 
> 
> Well, if you'd like to remove duplication, how about (untested)...
> 
> module ZenAcct
> 
>   class ZenCustomer < ZenRecord
>     
>     def initialize
>       super('CUSTOMER', 'c')
>       @subrecords = [
>         ZenAddress.new(self)
>         ZenPhone.new(self)
>         ZenBond.new(self)
>         ZenNote.new(self)
>         ZenURL.new(self)
>       ]
>     end
> 
>     # This would probably be in class ZenRecord...
> 
>     def invoke_sub(meth, *params)
>       @subrecords.each {|sr| sr.send(meth, *params)
>     end
> 
>     #
>     def action
>       super
>       invoke_sub(:action, @act)
>     end
>     
>     # Display the customer edit html
>     def display
>       @html = ZenCustomer_HTML.new(self)
>       $cgi.out { @html.html_page(@title, 'com') }
>     end
>     
>     #
>     def load_dbi
>       super
>       invoke_sub(:load_dbi)
>     end
>     
>     #
>     def references
>       ref = super
>       if @edit_new
>         invoke_sub(:update, @addresses.references)
>       end
>       return ref
>     end
>   
>     # ....
> 
> 
> 
> 
> Cheers
> 
> 
> Dave
> 
-- 
~transami

"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety."
	-- Benjamin Franklin