Commit e12a3877 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #99 from MobiRuby/const_missing

add Object.const_missing
parents c95279c6 885cb32d
......@@ -259,6 +259,16 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym)
}
c = c->super;
}
if (!c) {
c = mrb->object_class;
}
if (mrb_respond_to(mrb, mrb_obj_value(c), mrb_intern(mrb, "const_missing"))) {
mrb_value argv = mrb_symbol_value(sym);
return mrb_funcall_argv(mrb, mrb_obj_value(c), "const_missing", 1, &argv);
}
mrb_raise(mrb, E_NAME_ERROR, "uninitialized constant %s",
mrb_sym2name(mrb, sym));
/* not reached */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment