Created
October 19, 2011 11:14
-
-
Save haileys/1298003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './extension' | |
class A | |
def foo | |
puts "Success!" | |
end | |
end | |
class B | |
end | |
B.superclass = A | |
B.new.foo # prints "Success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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