From: Paul Brannan Date: 2007-09-28T22:23:28+09:00 Subject: Re: Making 'new' private in a C extension. 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