Skip to content

Instantly share code, notes, and snippets.

@haileys
Created October 19, 2011 11:14
Show Gist options
  • Save haileys/1298003 to your computer and use it in GitHub Desktop.
Save haileys/1298003 to your computer and use it in GitHub Desktop.
require './extension'
class A
def foo
puts "Success!"
end
end
class B
end
B.superclass = A
B.new.foo # prints "Success!"
#include "ruby.h"
VALUE superclass_set(VALUE self, VALUE super)
{
RCLASS_SUPER(self) = super;
RCLASS_M_TBL(self) = st_init_numtable();
OBJ_INFECT(self, super);
return super;
}
void Init_ruby_super()
{
rb_define_method(rb_cClass, "superclass=", superclass_set, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment