Hello everyone,

Trying to get my head around some of the subtleties of Ruby.  I've done
quite a bit of C/C++/Java and some Python programming, and the normal
way that I'd solve this problem (in pseudo-Java) would be:

interface SomeFeature
{
	void execute();
}

public class FeatureFactory
{
	private static class FeatureImpl implements SomeFeature
	{
		public FeatureImpl(String initParam1,
				String initParam2)
		{
		...
		}
		
		public void execute() { ... }
	}

	public SomeFeature createFeature()
	{
		return new FeatureImpl("param1", "param2");
	}
}

I've seen some of the previous threads on the list (starting from here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/60616), but
I don't see anything immediately obvious as to how to encapsulate the
creation of my concrete implementations of a common interface (even with
duck typing, there's an implied interface).

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).

It would appear that if you have 'require'd the appropriate files (or
can), you can create any instances you want.  Is there a way to
accomplish what I'm trying to do beyond saying "don't do that" in the
documentation?

Any assistance would be appreciated.

Thanks in advance,

ast

***************************************************************************************************
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.
***************************************************************************************************