Paul Brannan
9/28/2007 1:23:00 PM
On Fri, Sep 28, 2007 at 02:55:12AM +0900, alterego@sdf.lonestar.org wrote:
>
> Hello all,
>
> I'm writing a C extension, one of the classes I define can only be
> instantiated via a defined 'get_instance' singleton method. This method will
> only ever return one instance, that is, successive calls will always return
> exactly the same ruby object.
In Ruby, such a method is generally named 'instance' rather than
'get_instance'.
> My problem is that someone could still call 'new' on the class. I'd like to
> remove that possibility by making 'new' private. Unfortunately I can't for the
> life of me work out how.
VALUE rb_cFoo = rb_define_class("Foo", rb_cObject);
rb_undef_alloc_func(rb_cFoo);
Paul