Cheers, Gavin.  Thanks for the quick reply.  I figured there had to be a
way, but it wasn't something I remember reading in the pickaxe book or
anywhere else that I'd seen so far.

Thanks again,

ast

On Fri, 2005-08-19 at 16:10, Gavin Kistner wrote:
> On Aug 19, 2005, at 9:03 AM, Andrew S. Townley wrote:
> > The main issue here is that I want to prevent the client code from
> > instantiating their own objects.  The objects should be created  
> > only by
> > a factory of some sort (who has implementation-specific configuration
> > information about how to bootstrap them).
> 
> 
> class Foo
>      def self.make
>          self.new( rand )
>      end
> 
>      def initialize( id )
>          @id = id
>      end
> 
>      class << self
>          protected :new
>      end
> end
> 
> p f1 = Foo.make
> # => #<Foo:0x340858 @id=0.452814124524593>
> 
> p f2 = Foo.new( 12 )
> # => /Users/gkistner/Desktop/tmp.rb:16: protected method `new' called  
> for Foo:Class (NoMethodError)
> 

***************************************************************************************************
The information in this email is confidential and may be legally privileged.  Access to this email by anyone other than the intended addressee is unauthorized.  If you are not the intended recipient of this message, any review, disclosure, copying, distribution, retention, or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.  If you are not the intended recipient, please reply to or forward a copy of this message to the sender and delete the message, any attachments, and any copies thereof from your system.
***************************************************************************************************