Method: Module#private_class_method
- Defined in:
- vm_method.c
#private_class_method(symbol, ...) ⇒ Object #private_class_method(string, ...) ⇒ Object #private_class_method(array) ⇒ Object
Makes existing class methods private. Often used to hide the default constructor new.
String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted.
class SimpleSingleton # Not thread safe
private_class_method :new
def SimpleSingleton.create(*args, &block)
@me = new(*args, &block) if ! @me
@me
end
end
2685 2686 2687 2688 2689 2690 |
# File 'vm_method.c', line 2685
static VALUE
rb_mod_private_method(int argc, VALUE *argv, VALUE obj)
{
set_method_visibility(rb_singleton_class(obj), argc, argv, METHOD_VISI_PRIVATE);
return obj;
}
|