Skip to content
Permalink
Browse files

Module#const_added(name) hook

  • Loading branch information...
todesking committed Jan 21, 2013
1 parent 34a542c commit ff4112340a149faf18cbe288fee02a419f801bcc
Showing with 6 additions and 0 deletions.
  1. +1 −0 object.c
  2. +5 −0 variable.c
@@ -2675,6 +2675,7 @@ Init_Object(void)
rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1);
rb_define_private_method(rb_cModule, "const_added", rb_obj_dummy, 1);

rb_define_method(rb_mKernel, "nil?", rb_false, 0);
rb_define_method(rb_mKernel, "===", rb_equal, 1);
@@ -18,6 +18,7 @@
#include "node.h"
#include "constant.h"
#include "internal.h"
#include "vm_core.h"

st_table *rb_global_tbl;
st_table *rb_class_tbl;
@@ -1917,6 +1918,10 @@ rb_const_set(VALUE klass, ID id, VALUE val)
ce->value = val;

st_insert(RCLASS_CONST_TBL(klass), (st_data_t)id, (st_data_t)ce);

if (GET_VM()->running) {
rb_funcall(klass, rb_intern("const_added"), 1, ID2SYM(id));
}
}

void

0 comments on commit ff41123

Please sign in to comment.
You can’t perform that action at this time.