Skip to content

Commit

Permalink
Module#const_added(name) hook
Browse files Browse the repository at this point in the history
  • Loading branch information
todesking committed Jan 21, 2013
1 parent 34a542c commit ff41123
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions object.c
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions variable.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ff41123

Please sign in to comment.