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