I know about how initialize works, but on page 233 of the Pickaxe book
it describes somewhat of what I want to do.

Actually, let me clarify.  I don't want the user of the class to have to
worry about overriding "initialize in my parent class.

I actually want the code in a module which can be used asa mixin with an
include.

Better example:

module Foo
	def new
		# Do some stuff here...
		super
	end
end


class Bar

	include Foo

	def initialize
		# do some initialization stuff here...
	end
end


class Something < Foo
	def initialize
		# some stuff here, but want new from the parent called
		# implicitly...
	end
end

Another question I had come up right after I wrote this was what happens
to parameters passed to new in a case like this?

Mike


On Tue, Nov 20, 2001 at 10:06:15AM +0900, Matt Armstrong wrote:
> Michael Sullivan <mps / blackbird.discomsys.com> writes:
> 
> > Hi,
> >
> > I have a module I would like to do some initialization of a class when a
> > new instance is created.  What is the best way my initialization code
> > executes when a new instance of the object or a sub-class of the object
> > is instantiated?  I'd like this to be as transparent to the user as
> > possible.
> >
> > Should I define a "new" method in my module and then do a super?
> > Something like this:
> >
> > module Foo
> > 	def new
> > 		# do some stuff here....
> > 		super
> > 	end
> > end
> 
> Yes, except that the function should be called "initialize".  Ruby
> calls the "initialize" method on every object when it is created.
> 
> 
> > What are the implications of this?  Is there a better way to have
> > code execute upom instantiation of an object?  Even in a child
> > object?
> 
> If the child object doesn't call "super" in its implementation of
> "initialize" then the super class's "initialize" method won't be
> called.
> 
> -- 
> matt

-- 
Michael P. Sullivan                                  
Distributed Computing Systems, LLC                         Cell: 516-429-2080 
E-Mail: mps / discomsys.com                           http://www.discomsys.com/ 
    * UNIX Systems and Database Consulting, Architecture and Management *
"Failing to plan, is planning to fail... plan for the worst, hope for the best"