Method: Module#to_class

Defined in:
ext/evilr/evilr.c

#to_class(klass = Object) ⇒ Class

Makes a copy of the module, converts the copy to a class, and returns it. The returned class can then have instances created from it. The klass argument sets the superclass of the returned class. If klass is not a Class, raises TypeError.

Returns:



768
769
770
771
772
773
774
775
776
777
# File 'ext/evilr/evilr.c', line 768

static VALUE evilr_to_class(int argc, VALUE *argv, VALUE self) {
  VALUE klass = evilr__optional_class(argc, argv);

  self = rb_obj_clone(self);
  RBASIC_SET_KLASS(self, rb_singleton_class(klass));
  RCLASS_SET_SUPER(self, klass);
  FL_UNSET(self, T_MASK);
  FL_SET(self, T_CLASS);
  return self;
}